Commit c5fcdedc authored by Coly Li's avatar Coly Li Committed by Jens Axboe
Browse files

bcache: add idle_max_writeback_rate sysfs interface



For writeback mode, if there is no regular I/O request for a while,
the writeback rate will be set to the maximum value (1TB/s for now).
This is good for most of the storage workload, but there are still
people don't what the maximum writeback rate in I/O idle time.

This patch adds a sysfs interface file idle_max_writeback_rate to
permit people to disable maximum writeback rate. Then the minimum
writeback rate can be advised by writeback_rate_minimum in the
bcache device's sysfs interface.

Reported-by: default avatarChristian Balzer <chibi@gol.com>
Signed-off-by: default avatarColy Li <colyli@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 5dccefd3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -724,6 +724,7 @@ struct cache_set {
	unsigned int		gc_always_rewrite:1;
	unsigned int		shrinker_disabled:1;
	unsigned int		copy_gc_enabled:1;
	unsigned int		idle_max_writeback_rate_enabled:1;

#define BUCKET_HASH_BITS	12
	struct hlist_head	bucket_hash[1 << BUCKET_HASH_BITS];
+1 −0
Original line number Diff line number Diff line
@@ -1834,6 +1834,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
	c->congested_read_threshold_us	= 2000;
	c->congested_write_threshold_us	= 20000;
	c->error_limit	= DEFAULT_IO_ERROR_LIMIT;
	c->idle_max_writeback_rate_enabled = 1;
	WARN_ON(test_and_clear_bit(CACHE_SET_IO_DISABLE, &c->flags));

	return c;
+7 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ rw_attribute(expensive_debug_checks);
rw_attribute(cache_replacement_policy);
rw_attribute(btree_shrinker_disabled);
rw_attribute(copy_gc_enabled);
rw_attribute(idle_max_writeback_rate);
rw_attribute(gc_after_writeback);
rw_attribute(size);

@@ -747,6 +748,8 @@ SHOW(__bch_cache_set)
	sysfs_printf(gc_always_rewrite,		"%i", c->gc_always_rewrite);
	sysfs_printf(btree_shrinker_disabled,	"%i", c->shrinker_disabled);
	sysfs_printf(copy_gc_enabled,		"%i", c->copy_gc_enabled);
	sysfs_printf(idle_max_writeback_rate,	"%i",
		     c->idle_max_writeback_rate_enabled);
	sysfs_printf(gc_after_writeback,	"%i", c->gc_after_writeback);
	sysfs_printf(io_disable,		"%i",
		     test_bit(CACHE_SET_IO_DISABLE, &c->flags));
@@ -864,6 +867,9 @@ STORE(__bch_cache_set)
	sysfs_strtoul_bool(gc_always_rewrite,	c->gc_always_rewrite);
	sysfs_strtoul_bool(btree_shrinker_disabled, c->shrinker_disabled);
	sysfs_strtoul_bool(copy_gc_enabled,	c->copy_gc_enabled);
	sysfs_strtoul_bool(idle_max_writeback_rate,
			   c->idle_max_writeback_rate_enabled);

	/*
	 * write gc_after_writeback here may overwrite an already set
	 * BCH_DO_AUTO_GC, it doesn't matter because this flag will be
@@ -954,6 +960,7 @@ static struct attribute *bch_cache_set_internal_files[] = {
	&sysfs_gc_always_rewrite,
	&sysfs_btree_shrinker_disabled,
	&sysfs_copy_gc_enabled,
	&sysfs_idle_max_writeback_rate,
	&sysfs_gc_after_writeback,
	&sysfs_io_disable,
	&sysfs_cutoff_writeback,
+4 −0
Original line number Diff line number Diff line
@@ -122,6 +122,10 @@ static void __update_writeback_rate(struct cached_dev *dc)
static bool set_at_max_writeback_rate(struct cache_set *c,
				       struct cached_dev *dc)
{
	/* Don't sst max writeback rate if it is disabled */
	if (!c->idle_max_writeback_rate_enabled)
		return false;

	/* Don't set max writeback rate if gc is running */
	if (!c->gc_mark_valid)
		return false;