diff options
author | Coly Li <colyli@suse.de> | 2018-11-22 22:35:04 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2018-11-22 22:35:04 +0800 |
commit | 018c81d33fabb1bcbac8ae0a9b63638eff468999 (patch) | |
tree | ffcd726de424ca85ed6cd3458cc8b14acaa8e6c3 | |
parent | c15e0e770e0a6f221a6bda9676d003c244154d4d (diff) | |
download | bcache-patches-018c81d33fabb1bcbac8ae0a9b63638eff468999.tar.gz |
for-next: add patches from for-test since they are well tested
-rw-r--r-- | for-next/0001-bcache-introduce-force_wake_up_gc.patch | 82 | ||||
-rw-r--r-- | for-next/0002-bcache-option-to-automatically-run-gc-thread-after-w.patch (renamed from for-test/0001-bcache-permit-to-wake-up-gc-thread-after-writeback-c.patch) | 51 | ||||
-rw-r--r-- | for-next/0003-bcache-add-MODULE_DESCRIPTION-information.patch (renamed from for-test/0002-bcache-add-MODULE_DESCRIPTION-information.patch) | 6 | ||||
-rw-r--r-- | for-next/0004-bcache-make-cutoff_writeback-and-cutoff_writeback_sy.patch (renamed from for-test/0003-bcache-make-cutoff_writeback-and-cutoff_writeback_sy.patch) | 40 | ||||
-rw-r--r-- | for-next/0005-bcache-set-writeback_percent-in-a-flexible-range.patch | 43 | ||||
-rw-r--r-- | for-test/0004-bcache-set-writebac_percent-in-a-dynamic-range.patch | 29 |
6 files changed, 188 insertions, 63 deletions
diff --git a/for-next/0001-bcache-introduce-force_wake_up_gc.patch b/for-next/0001-bcache-introduce-force_wake_up_gc.patch new file mode 100644 index 0000000..1d79724 --- /dev/null +++ b/for-next/0001-bcache-introduce-force_wake_up_gc.patch @@ -0,0 +1,82 @@ +From 6fbbcf035832ea5eb992b40bc6cd06aef309a97a Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Thu, 22 Nov 2018 20:22:58 +0800 +Subject: [PATCH 1/5] bcache: introduce force_wake_up_gc() + +Garbage collection thread starts to work when c->sectors_to_gc is +negative value, otherwise nothing will happen even the gc thread +is woken up by wake_up_gc(). + +force_wake_up_gc() sets c->sectors_to_gc to -1 before calling +wake_up_gc(), then gc thread may have chance to run if no one else +sets c->sectors_to_gc to a positive value before gc_should_run(). + +This routine can be called where the gc thread is woken up and +required to run in force. + +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/btree.h | 18 ++++++++++++++++++ + drivers/md/bcache/sysfs.c | 17 ++--------------- + 2 files changed, 20 insertions(+), 15 deletions(-) + +diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h +index a68d6c55783b..fa72c5a5e058 100644 +--- a/drivers/md/bcache/btree.h ++++ b/drivers/md/bcache/btree.h +@@ -266,6 +266,24 @@ static inline void wake_up_gc(struct cache_set *c) + wake_up(&c->gc_wait); + } + ++static inline void force_wake_up_gc(struct cache_set *c) ++{ ++ /* ++ * Garbage collection thread only works when sectors_to_gc < 0, ++ * calling wake_up_gc() won't start gc thread if sectors_to_gc is ++ * not a nagetive value. ++ * Therefore sectors_to_gc is set to -1 here, before waking up ++ * gc thread by calling wake_up_gc(). Then gc_should_run() will ++ * give a chance to permit gc thread to run. "Give a chance" means ++ * before going into gc_should_run(), there is still possibility ++ * that c->sectors_to_gc being set to other positive value. So ++ * this routine won't 100% make sure gc thread will be woken up ++ * to run. ++ */ ++ atomic_set(&c->sectors_to_gc, -1); ++ wake_up_gc(c); ++} ++ + #define MAP_DONE 0 + #define MAP_CONTINUE 1 + +diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c +index 26f035a0c5b9..0e48397cb6d3 100644 +--- a/drivers/md/bcache/sysfs.c ++++ b/drivers/md/bcache/sysfs.c +@@ -725,21 +725,8 @@ STORE(__bch_cache_set) + bch_cache_accounting_clear(&c->accounting); + } + +- if (attr == &sysfs_trigger_gc) { +- /* +- * Garbage collection thread only works when sectors_to_gc < 0, +- * when users write to sysfs entry trigger_gc, most of time +- * they want to forcibly triger gargage collection. Here -1 is +- * set to c->sectors_to_gc, to make gc_should_run() give a +- * chance to permit gc thread to run. "give a chance" means +- * before going into gc_should_run(), there is still chance +- * that c->sectors_to_gc being set to other positive value. So +- * writing sysfs entry trigger_gc won't always make sure gc +- * thread takes effect. +- */ +- atomic_set(&c->sectors_to_gc, -1); +- wake_up_gc(c); +- } ++ if (attr == &sysfs_trigger_gc) ++ force_wake_up_gc(c); + + if (attr == &sysfs_prune_cache) { + struct shrink_control sc; +-- +2.16.4 + diff --git a/for-test/0001-bcache-permit-to-wake-up-gc-thread-after-writeback-c.patch b/for-next/0002-bcache-option-to-automatically-run-gc-thread-after-w.patch index 68ecdaf..f772876 100644 --- a/for-test/0001-bcache-permit-to-wake-up-gc-thread-after-writeback-c.patch +++ b/for-next/0002-bcache-option-to-automatically-run-gc-thread-after-w.patch @@ -1,16 +1,32 @@ -From eefd4b8400e584ce7b2abcf417fabc8b0eb5c979 Mon Sep 17 00:00:00 2001 +From 23ca72d25b910e558d7ff6507b36dc1982f5c1b1 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Thu, 15 Nov 2018 20:52:03 +0800 -Subject: [PATCH 1/4] bcache: permit to wake up gc thread after writeback - completed +Subject: [PATCH 2/5] bcache: option to automatically run gc thread after + writeback accomplished + +The option gc_after_writeback is disabled by default, because garbage +collection will discard SSD data which drops cached data. + +Echo 1 into /sys/fs/bcache/<UUID>/internal/gc_after_writeback will enable +this option, which wakes up gc thread when writeback accomplished and all +cached data is clean. + +This option is helpful for people who cares writing performance more. +In heavy writing workload, all cached data can be clean only happens when +writeback thread cleans all cached data in I/O idle time. In such +situation a following gc running may help to shrink bcache B+ tree and +discard more clean data, which may be helpful for future writing requests. + +If you are not sure whether this is helpful for your own workload, please +leave it as disabled by default. Signed-off-by: Coly Li <colyli@suse.de> --- drivers/md/bcache/bcache.h | 14 ++++++++++++++ - drivers/md/bcache/sysfs.c | 11 +++++++++++ + drivers/md/bcache/sysfs.c | 9 +++++++++ drivers/md/bcache/writeback.c | 27 +++++++++++++++++++++++++++ drivers/md/bcache/writeback.h | 2 ++ - 4 files changed, 54 insertions(+) + 4 files changed, 52 insertions(+) diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index b61b83bbcfff..743f8615b85a 100644 @@ -38,7 +54,7 @@ index b61b83bbcfff..743f8615b85a 100644 * The allocation code needs gc_mark in struct bucket to be correct, but * it's not while a gc is in progress. Protected by bucket_lock. diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c -index 26f035a0c5b9..549950c5ef8c 100644 +index 0e48397cb6d3..f94e0094ca28 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -128,6 +128,7 @@ rw_attribute(expensive_debug_checks); @@ -49,24 +65,15 @@ index 26f035a0c5b9..549950c5ef8c 100644 rw_attribute(size); static ssize_t bch_snprint_string_list(char *buf, -@@ -324,6 +325,7 @@ STORE(__cached_dev) - dc->stop_when_cache_set_failed = v; - } - -+ - if (attr == &sysfs_label) { - if (size > SB_LABEL_SIZE) - return -EINVAL; -@@ -676,6 +678,8 @@ SHOW(__bch_cache_set) +@@ -676,6 +677,7 @@ 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(gc_after_writeback, "%i", -+ c->gc_after_writeback & BCH_ENABLE_AUTO_GC); ++ sysfs_printf(gc_after_writeback, "%i", c->gc_after_writeback); sysfs_printf(io_disable, "%i", test_bit(CACHE_SET_IO_DISABLE, &c->flags)); -@@ -789,6 +793,12 @@ STORE(__bch_cache_set) +@@ -776,6 +778,12 @@ STORE(__bch_cache_set) sysfs_strtoul(gc_always_rewrite, c->gc_always_rewrite); sysfs_strtoul(btree_shrinker_disabled, c->shrinker_disabled); sysfs_strtoul(copy_gc_enabled, c->copy_gc_enabled); @@ -79,7 +86,7 @@ index 26f035a0c5b9..549950c5ef8c 100644 return size; } -@@ -869,6 +879,7 @@ static struct attribute *bch_cache_set_internal_files[] = { +@@ -856,6 +864,7 @@ static struct attribute *bch_cache_set_internal_files[] = { &sysfs_gc_always_rewrite, &sysfs_btree_shrinker_disabled, &sysfs_copy_gc_enabled, @@ -88,7 +95,7 @@ index 26f035a0c5b9..549950c5ef8c 100644 NULL }; diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c -index 08c3a9f9676c..9b23899310ce 100644 +index 08c3a9f9676c..74e3f5f3807b 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -17,6 +17,15 @@ @@ -134,7 +141,7 @@ index 08c3a9f9676c..9b23899310ce 100644 + if (c->gc_after_writeback == + (BCH_ENABLE_AUTO_GC|BCH_DO_AUTO_GC)) { + c->gc_after_writeback &= ~BCH_DO_AUTO_GC; -+ wake_up_gc(c); ++ force_wake_up_gc(c); + } } @@ -153,5 +160,5 @@ index d2b9fdbc8994..ce63be98a39d 100644 * 14 (16384ths) is chosen here as something that each backing device * should be a reasonable fraction of the share, and not to blow up -- -2.19.1 +2.16.4 diff --git a/for-test/0002-bcache-add-MODULE_DESCRIPTION-information.patch b/for-next/0003-bcache-add-MODULE_DESCRIPTION-information.patch index d0dd9bc..75728e3 100644 --- a/for-test/0002-bcache-add-MODULE_DESCRIPTION-information.patch +++ b/for-next/0003-bcache-add-MODULE_DESCRIPTION-information.patch @@ -1,7 +1,7 @@ -From 397e7467056be50e95c52de12079ddd973b42274 Mon Sep 17 00:00:00 2001 +From 3a09e80788126f6b13b81e773359051e25d7b3f1 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Tue, 20 Nov 2018 17:40:52 +0800 -Subject: [PATCH 2/4] bcache: add MODULE_DESCRIPTION information +Subject: [PATCH 3/5] bcache: add MODULE_DESCRIPTION information This patch moves MODULE_AUTHOR and MODULE_LICENSE to end of super.c, and add MODULE_DESCRIPTION("Bcache: a Linux block layer cache"). @@ -36,5 +36,5 @@ index 7bbd670a5a84..5d9788dc4976 100644 +MODULE_AUTHOR("Kent Overstreet <kent.overstreet@gmail.com>"); +MODULE_LICENSE("GPL"); -- -2.19.1 +2.16.4 diff --git a/for-test/0003-bcache-make-cutoff_writeback-and-cutoff_writeback_sy.patch b/for-next/0004-bcache-make-cutoff_writeback-and-cutoff_writeback_sy.patch index d420b1e..ccb9b40 100644 --- a/for-test/0003-bcache-make-cutoff_writeback-and-cutoff_writeback_sy.patch +++ b/for-next/0004-bcache-make-cutoff_writeback-and-cutoff_writeback_sy.patch @@ -1,14 +1,36 @@ -From 97019eff029772e75c4de2b9553acc8394f5b959 Mon Sep 17 00:00:00 2001 +From bd505272ff1e88f13e4af0133790cb31a450859d Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Tue, 20 Nov 2018 22:50:31 +0800 -Subject: [PATCH 3/4] bcache: make cutoff_writeback and cutoff_writeback_sync +Subject: [PATCH 4/5] bcache: make cutoff_writeback and cutoff_writeback_sync tunnable +Currently the cutoff writeback and cutoff writeback sync thresholds are +defined by CUTOFF_WRITEBACK (40) and CUTOFF_WRITEBACK_SYNC (70) as static +values. Most of time these they work fine, but when people want to do +research on bcache writeback mode performance tunning, there is no chance +to modify the soft and hard cutoff writeback values. + +This patch introduces two module parameters bch_cutoff_writeback_sync and +bch_cutoff_writeback which permit people to tune the values when loading +bcache.ko. If they are not specified by module loading, current values +CUTOFF_WRITEBACK_SYNC and CUTOFF_WRITEBACK will be used as default and +nothing changes. + +When people want to tune this two values, +- cutoff_writeback can be set in range [1, 70] +- cutoff_writeback_sync can be set in range [1, 90] +- cutoff_writeback always <= cutoff_writeback_sync + +The default values are strongly recommended to most of users for most of +workloads. Anyway, if people wants to take their own risk to do research +on new writeback cutoff tunning for their own workload, now they can +make it. + Signed-off-by: Coly Li <colyli@suse.de> --- - drivers/md/bcache/super.c | 40 +++++++++++++++++++++++++++++++++++ - drivers/md/bcache/sysfs.c | 7 ++++++ - drivers/md/bcache/writeback.h | 10 +++++++-- + drivers/md/bcache/super.c | 40 ++++++++++++++++++++++++++++++++++++++++ + drivers/md/bcache/sysfs.c | 7 +++++++ + drivers/md/bcache/writeback.h | 10 ++++++++-- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c @@ -87,7 +109,7 @@ index 5d9788dc4976..7807fd600fa0 100644 MODULE_AUTHOR("Kent Overstreet <kent.overstreet@gmail.com>"); MODULE_LICENSE("GPL"); diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c -index 549950c5ef8c..e87aa6cac354 100644 +index f94e0094ca28..47d2f6cce11b 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -88,6 +88,8 @@ read_attribute(writeback_keys_done); @@ -99,7 +121,7 @@ index 549950c5ef8c..e87aa6cac354 100644 rw_attribute(congested_read_threshold_us); rw_attribute(congested_write_threshold_us); -@@ -670,6 +672,9 @@ SHOW(__bch_cache_set) +@@ -669,6 +671,9 @@ SHOW(__bch_cache_set) sysfs_print(congested_write_threshold_us, c->congested_write_threshold_us); @@ -109,7 +131,7 @@ index 549950c5ef8c..e87aa6cac354 100644 sysfs_print(active_journal_entries, fifo_used(&c->journal.pin)); sysfs_printf(verify, "%i", c->verify); sysfs_printf(key_merging_disabled, "%i", c->key_merging_disabled); -@@ -881,6 +886,8 @@ static struct attribute *bch_cache_set_internal_files[] = { +@@ -866,6 +871,8 @@ static struct attribute *bch_cache_set_internal_files[] = { &sysfs_copy_gc_enabled, &sysfs_gc_after_writeback, &sysfs_io_disable, @@ -161,5 +183,5 @@ index ce63be98a39d..6a743d3bb338 100644 static inline void bch_writeback_queue(struct cached_dev *dc) -- -2.19.1 +2.16.4 diff --git a/for-next/0005-bcache-set-writeback_percent-in-a-flexible-range.patch b/for-next/0005-bcache-set-writeback_percent-in-a-flexible-range.patch new file mode 100644 index 0000000..f4b8cca --- /dev/null +++ b/for-next/0005-bcache-set-writeback_percent-in-a-flexible-range.patch @@ -0,0 +1,43 @@ +From 31b5731bfedae70457d58dd2700062d46ac07e79 Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Tue, 20 Nov 2018 22:53:40 +0800 +Subject: [PATCH 5/5] bcache: set writeback_percent in a flexible range + +Because CUTOFF_WRITEBACK is defined as 40, so before the changes of +dynamic cutoff writeback values, writeback_percent is limited to +[0, CUTOFF_WRITEBACK]. Any value larger than CUTOFF_WRITEBACK will +be fixed up to 40. + +Now cutof writeback limit is a dynamic value bch_cutoff_writeback, +so the range of writeback_percent can be a more flexible range as +[0, bch_cutoff_writeback]. The flexibility is, it can be expended +to a larger or smaller range than [0, 40], depends on how value +bch_cutoff_writeback is specified. + +The default value is still strongly recommended to most of users for +most of workloads. But for people who want to do research on bcache +writeback perforamnce tunning, they may have chance to specify more +flexible writeback_percent in range [0, 70]. + +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/sysfs.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c +index 47d2f6cce11b..3b235b76add5 100644 +--- a/drivers/md/bcache/sysfs.c ++++ b/drivers/md/bcache/sysfs.c +@@ -267,7 +267,8 @@ STORE(__cached_dev) + d_strtoul(writeback_running); + d_strtoul(writeback_delay); + +- sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent, 0, 40); ++ sysfs_strtoul_clamp(writeback_percent,dc->writeback_percent, ++ 0, bch_cutoff_writeback); + + if (attr == &sysfs_writeback_rate) { + ssize_t ret; +-- +2.16.4 + diff --git a/for-test/0004-bcache-set-writebac_percent-in-a-dynamic-range.patch b/for-test/0004-bcache-set-writebac_percent-in-a-dynamic-range.patch deleted file mode 100644 index 7cd8689..0000000 --- a/for-test/0004-bcache-set-writebac_percent-in-a-dynamic-range.patch +++ /dev/null @@ -1,29 +0,0 @@ -From e1dda689b3642f15836a1d7055d14d02aa1d5dad Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Tue, 20 Nov 2018 22:53:40 +0800 -Subject: [PATCH 4/4] bcache: set writebac_percent in a dynamic range - -permit to set writeback_percent in [0, bch_cutoff_writeback]. - -Signed-off-by: Coly Li <colyli@suse.de> ---- - drivers/md/bcache/sysfs.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c -index e87aa6cac354..98fe3e9f15b3 100644 ---- a/drivers/md/bcache/sysfs.c -+++ b/drivers/md/bcache/sysfs.c -@@ -267,7 +267,8 @@ STORE(__cached_dev) - d_strtoul(writeback_running); - d_strtoul(writeback_delay); - -- sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent, 0, 40); -+ sysfs_strtoul_clamp(writeback_percent,dc->writeback_percent, -+ 0, bch_cutoff_writeback); - - if (attr == &sysfs_writeback_rate) { - ssize_t ret; --- -2.19.1 - |