diff options
author | Coly Li <colyli@suse.de> | 2019-06-06 00:29:06 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2019-06-06 00:29:06 +0800 |
commit | 47316e3d28fa472a155682c457c6fab000f62c65 (patch) | |
tree | 6a35296e752c3baf7a132f352de451d0d4b9d9a3 | |
parent | d89fd20daa9a3e982d567d5ce2f097376c259052 (diff) | |
download | bcache-patches-47316e3d28fa472a155682c457c6fab000f62c65.tar.gz |
for-test: resort testing patches
-rw-r--r-- | for-test/0001-bcache-avoid-a-deadlock-in-bcache_reboot.patch (renamed from for-test/for-5.3/reboot-deadlock/0003-bcache-avoid-a-deadlock-in-bcache_reboot.patch) | 14 | ||||
-rw-r--r-- | for-test/0004-bcache-fix-potential-deadlock-in-cached_def_free.patch (renamed from for-test/for-5.3/reboot-deadlock/0004-bcache-fix-potential-deadlock-in-cached_def_free.patch) | 42 | ||||
-rw-r--r-- | for-test/for-5.3/0000-cover-letter.patch | 33 | ||||
-rw-r--r-- | for-test/for-5.3/reboot-deadlock/.0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | for-test/for-5.3/reboot-deadlock/0000-cover-letter.patch | 10 | ||||
-rw-r--r-- | for-test/for-5.3/reboot-deadlock/0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch | 38 | ||||
-rw-r--r-- | for-test/for-5.3/reboot-deadlock/0002-bcache-acquire-bch_register_lock-later-in-cached_dev.patch | 35 | ||||
-rw-r--r-- | for-test/for-5.3/reboot-deadlock/0003-bcache-acquire-bch_register_lock-later-in-cached_dev.patch | 39 |
8 files changed, 108 insertions, 103 deletions
diff --git a/for-test/for-5.3/reboot-deadlock/0003-bcache-avoid-a-deadlock-in-bcache_reboot.patch b/for-test/0001-bcache-avoid-a-deadlock-in-bcache_reboot.patch index cf32630..e0e2159 100644 --- a/for-test/for-5.3/reboot-deadlock/0003-bcache-avoid-a-deadlock-in-bcache_reboot.patch +++ b/for-test/0001-bcache-avoid-a-deadlock-in-bcache_reboot.patch @@ -1,7 +1,7 @@ -From 55a992900d82d2fdda05b203e40a2c8400684310 Mon Sep 17 00:00:00 2001 +From afa37213a977d001e8882899469c4995266f2b0b Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Tue, 21 May 2019 23:19:55 +0800 -Subject: [PATCH 3/4] bcache: avoid a deadlock in bcache_reboot() +Subject: [PATCH 1/4] bcache: avoid a deadlock in bcache_reboot() It is quite frequently to observe deadlock in bcache_reboot() happens and hang the system reboot process. The reason is, in bcache_reboot() @@ -30,7 +30,7 @@ Signed-off-by: Coly Li <colyli@suse.de> 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 2045bce58abe..a5e2f500d96d 100644 +index 16ed617183f7..8a1e8217207a 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -40,6 +40,7 @@ static const char invalid_uuid[] = { @@ -49,7 +49,7 @@ index 2045bce58abe..a5e2f500d96d 100644 #define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE) /* limitation of partitions number on single bcache device */ #define BCACHE_MINORS 128 -@@ -2346,6 +2348,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, +@@ -2345,6 +2347,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, if (!try_module_get(THIS_MODULE)) return -EBUSY; @@ -61,7 +61,7 @@ index 2045bce58abe..a5e2f500d96d 100644 path = kstrndup(buffer, size, GFP_KERNEL); if (!path) goto err; -@@ -2475,6 +2482,9 @@ static ssize_t bch_pending_bdevs_cleanup(struct kobject *k, +@@ -2474,6 +2481,9 @@ static ssize_t bch_pending_bdevs_cleanup(struct kobject *k, static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) { @@ -71,7 +71,7 @@ index 2045bce58abe..a5e2f500d96d 100644 if (code == SYS_DOWN || code == SYS_HALT || code == SYS_POWER_OFF) { -@@ -2487,19 +2497,46 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) +@@ -2486,19 +2496,46 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) mutex_lock(&bch_register_lock); @@ -119,7 +119,7 @@ index 2045bce58abe..a5e2f500d96d 100644 /* * Give an early chance for other kthreads and -@@ -2627,6 +2664,8 @@ static int __init bcache_init(void) +@@ -2626,6 +2663,8 @@ static int __init bcache_init(void) bch_debug_init(); closure_debug_init(); diff --git a/for-test/for-5.3/reboot-deadlock/0004-bcache-fix-potential-deadlock-in-cached_def_free.patch b/for-test/0004-bcache-fix-potential-deadlock-in-cached_def_free.patch index debc712..4c47dc5 100644 --- a/for-test/for-5.3/reboot-deadlock/0004-bcache-fix-potential-deadlock-in-cached_def_free.patch +++ b/for-test/0004-bcache-fix-potential-deadlock-in-cached_def_free.patch @@ -1,11 +1,11 @@ -From f92748bda5950c52856c22f75bdb597070dc106f Mon Sep 17 00:00:00 2001 +From d610131755e37adcfad2ecb5a1ce34c481b6a15c Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> Date: Tue, 4 Jun 2019 14:28:33 +0800 Subject: [PATCH 4/4] bcache: fix potential deadlock in cached_def_free() -This patch moves destroying dc->writeback_write_wq from cached_dev_free() -to bch_writeback_thread(). Then a potential deadlock reported by lockdep -engine can be fixed: +When enable lockdep and reboot system with a writeback mode bcache +device, the following potential deadlock warning is reported by lockdep +engine. [ 325.736697][ T3394] ====================================================== @@ -61,39 +61,11 @@ lock((work_completion)(&cl->work)#2); [ 329.756566][ T3394] [ 329.756568][ T3394] 2 locks held by kworker/32:8/3394: [ 329.908637][ T3394] #0: 00000000a9fd42af -((wq_completion)bcache_mod_wq){+.+.}, at: process_one_work+0x1b5/0x5e0 +((wq_completion)system_wq){+.+.}, at: process_one_work+0x1b5/0x5e0 [ 330.055510][ T3394] #1: 00000000efbccbbd ((work_completion)(&cl->work)#2){+.+.}, at: process_one_work+0x1b5/0x5e0 -[ 330.153501][ T3394] -[ 330.153501][ T3394] stack backtrace: -[ 330.153504][ T3394] CPU: 32 PID: 3394 Comm: kworker/32:8 Tainted: G - W 5.1.0-lp151.28.4-default+ #5 -[ 330.311808][ T3394] Hardware name: Lenovo ThinkSystem SR650 --[7X05CTO1WW]-/-[7X05CTO1WW]-, BIOS -[IVE136T-2.10]- 03/22/2019 -[ 330.311815][ T3394] Workqueue: bcache_mod_wq cached_dev_free [bcache] -[ 330.431640][ T3394] Call Trace: -[ 330.431644][ T3394] dump_stack+0x85/0xcb -[ 330.562909][ T3394] print_circular_bug+0x19a/0x1f0 -[ 330.692101][ T3394] __lock_acquire+0x177e/0x17d0 -[ 330.844173][ T3394] ? __lock_acquire+0x69a/0x17d0 -[ 331.009763][ T3394] ? lock_acquire+0xb4/0x1c0 -[ 331.139994][ T3394] ? find_held_lock+0x34/0xa0 -[ 331.139997][ T3394] lock_acquire+0xb4/0x1c0 -[ 331.293107][ T3394] ? flush_workqueue+0x87/0x540 -[ 331.411893][ T3394] flush_workqueue+0xaa/0x540 -[ 331.596203][ T3394] ? flush_workqueue+0x87/0x540 -[ 331.596206][ T3394] ? sched_clock+0x5/0x10 -[ 331.768030][ T3394] ? drain_workqueue+0xa9/0x180 -[ 331.959621][ T3394] drain_workqueue+0xa9/0x180 -[ 331.959624][ T3394] destroy_workqueue+0x17/0x250 -[ 332.157456][ T3394] cached_dev_free+0x5b/0x200 [bcache] -[ 332.296003][ T3394] process_one_work+0x23b/0x5e0 -[ 332.381511][ T3394] worker_thread+0x3c/0x390 -[ 332.494057][ T3394] ? process_one_work+0x5e0/0x5e0 -[ 332.604523][ T3394] kthread+0x125/0x140 -[ 332.604526][ T3394] ? kthread_create_worker_on_cpu+0x70/0x70 -[ 332.709790][ T3394] ret_from_fork+0x3a/0x50 -[ 337.090520][ T3394] bcache: cached_dev_free() + + Signed-off-by: Coly Li <colyli@suse.de> --- diff --git a/for-test/for-5.3/0000-cover-letter.patch b/for-test/for-5.3/0000-cover-letter.patch new file mode 100644 index 0000000..edc9b57 --- /dev/null +++ b/for-test/for-5.3/0000-cover-letter.patch @@ -0,0 +1,33 @@ +From f92748bda5950c52856c22f75bdb597070dc106f Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Wed, 5 Jun 2019 16:46:31 +0800 +Subject: [PATCH 0/4] fix potential deadlock during reboot + +Hi folks, + +This series is fixes for potential deadlock during system reboot. All +the potential deadlocks are reported by lockdep engine. All the deadlock +is A-A lock type, idea of the fixes is to avoid recursive locking on +bch_register_lock or kthread/kwork lock. + +Any comment or review is welcome. + +Thanks in advance. + +Coly Li +--- + +Coly Li (4): + bcache: acquire bch_register_lock later in cached_dev_detach_finish() + bcache: acquire bch_register_lock later in cached_dev_free() + bcache: avoid a deadlock in bcache_reboot() + bcache: fix potential deadlock in cached_def_free() + + drivers/md/bcache/super.c | 50 +++++++++++++++++++++++++++++++++++++------ + drivers/md/bcache/sysfs.c | 26 ++++++++++++++++++++++ + drivers/md/bcache/writeback.c | 4 ++++ + 3 files changed, 74 insertions(+), 6 deletions(-) + +-- +2.16.4 + diff --git a/for-test/for-5.3/reboot-deadlock/.0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch.swp b/for-test/for-5.3/reboot-deadlock/.0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch.swp Binary files differdeleted file mode 100644 index e92cf8a..0000000 --- a/for-test/for-5.3/reboot-deadlock/.0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch.swp +++ /dev/null diff --git a/for-test/for-5.3/reboot-deadlock/0000-cover-letter.patch b/for-test/for-5.3/reboot-deadlock/0000-cover-letter.patch index edc9b57..0608329 100644 --- a/for-test/for-5.3/reboot-deadlock/0000-cover-letter.patch +++ b/for-test/for-5.3/reboot-deadlock/0000-cover-letter.patch @@ -1,6 +1,6 @@ -From f92748bda5950c52856c22f75bdb597070dc106f Mon Sep 17 00:00:00 2001 +From d610131755e37adcfad2ecb5a1ce34c481b6a15c Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> -Date: Wed, 5 Jun 2019 16:46:31 +0800 +Date: Wed, 5 Jun 2019 23:06:04 +0800 Subject: [PATCH 0/4] fix potential deadlock during reboot Hi folks, @@ -12,15 +12,15 @@ bch_register_lock or kthread/kwork lock. Any comment or review is welcome. -Thanks in advance. - +Thanks in advance. + Coly Li --- Coly Li (4): + bcache: avoid a deadlock in bcache_reboot() bcache: acquire bch_register_lock later in cached_dev_detach_finish() bcache: acquire bch_register_lock later in cached_dev_free() - bcache: avoid a deadlock in bcache_reboot() bcache: fix potential deadlock in cached_def_free() drivers/md/bcache/super.c | 50 +++++++++++++++++++++++++++++++++++++------ diff --git a/for-test/for-5.3/reboot-deadlock/0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch b/for-test/for-5.3/reboot-deadlock/0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch deleted file mode 100644 index 7112d1b..0000000 --- a/for-test/for-5.3/reboot-deadlock/0001-bcache-acquire-bch_register_lock-later-in-cached_dev.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 8ab5851a8eb123096b9fd2a3b9f24f1ba2fe2fb9 Mon Sep 17 00:00:00 2001 -From: Coly Li <colyli@suse.de> -Date: Sun, 2 Jun 2019 01:06:12 +0800 -Subject: [PATCH 1/4] bcache: acquire bch_register_lock later in - cached_dev_detach_finish() - -To avoid potential deadlock on bch_register_lock when stopping kthread -or cancel kworker (which is done in sync way) - -Signed-off-by: Coly Li <colyli@suse.de> ---- - drivers/md/bcache/super.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 16ed617183f7..2a71898e9a30 100644 ---- a/drivers/md/bcache/super.c -+++ b/drivers/md/bcache/super.c -@@ -1016,7 +1016,6 @@ static void cached_dev_detach_finish(struct work_struct *w) - BUG_ON(!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)); - BUG_ON(refcount_read(&dc->count)); - -- mutex_lock(&bch_register_lock); - - if (test_and_clear_bit(BCACHE_DEV_WB_RUNNING, &dc->disk.flags)) - cancel_writeback_rate_update_dwork(dc); -@@ -1032,6 +1031,8 @@ static void cached_dev_detach_finish(struct work_struct *w) - bch_write_bdev_super(dc, &cl); - closure_sync(&cl); - -+ mutex_lock(&bch_register_lock); -+ - calc_cached_dev_sectors(dc->disk.c); - bcache_device_detach(&dc->disk); - list_move(&dc->list, &uncached_devices); --- -2.16.4 - diff --git a/for-test/for-5.3/reboot-deadlock/0002-bcache-acquire-bch_register_lock-later-in-cached_dev.patch b/for-test/for-5.3/reboot-deadlock/0002-bcache-acquire-bch_register_lock-later-in-cached_dev.patch index a08b565..c8354ce 100644 --- a/for-test/for-5.3/reboot-deadlock/0002-bcache-acquire-bch_register_lock-later-in-cached_dev.patch +++ b/for-test/for-5.3/reboot-deadlock/0002-bcache-acquire-bch_register_lock-later-in-cached_dev.patch @@ -1,38 +1,37 @@ -From d44338aae101ef946ca61732e16bf96039436f18 Mon Sep 17 00:00:00 2001 +From 1dc4c53cf8037506f8aadbff1f02ae3a40e0f96f Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@suse.de> -Date: Wed, 5 Jun 2019 16:37:50 +0800 +Date: Sun, 2 Jun 2019 01:06:12 +0800 Subject: [PATCH 2/4] bcache: acquire bch_register_lock later in - cached_dev_free() + cached_dev_detach_finish() -to avoid deadlock when stopping workqueue. +This patch is unncessary Signed-off-by: Coly Li <colyli@suse.de> --- - drivers/md/bcache/super.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) + drivers/md/bcache/super.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 2a71898e9a30..2045bce58abe 100644 +index 8a1e8217207a..65ebca4446d9 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c -@@ -1221,8 +1221,6 @@ static void cached_dev_free(struct closure *cl) - { - struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl); +@@ -1018,7 +1018,6 @@ static void cached_dev_detach_finish(struct work_struct *w) + BUG_ON(!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)); + BUG_ON(refcount_read(&dc->count)); - mutex_lock(&bch_register_lock); -- + if (test_and_clear_bit(BCACHE_DEV_WB_RUNNING, &dc->disk.flags)) cancel_writeback_rate_update_dwork(dc); - -@@ -1233,6 +1231,8 @@ static void cached_dev_free(struct closure *cl) - if (!IS_ERR_OR_NULL(dc->status_update_thread)) - kthread_stop(dc->status_update_thread); +@@ -1034,6 +1033,8 @@ static void cached_dev_detach_finish(struct work_struct *w) + bch_write_bdev_super(dc, &cl); + closure_sync(&cl); + mutex_lock(&bch_register_lock); + - if (atomic_read(&dc->running)) - bd_unlink_disk_holder(dc->bdev, dc->disk.disk); - bcache_device_free(&dc->disk); + calc_cached_dev_sectors(dc->disk.c); + bcache_device_detach(&dc->disk); + list_move(&dc->list, &uncached_devices); -- 2.16.4 diff --git a/for-test/for-5.3/reboot-deadlock/0003-bcache-acquire-bch_register_lock-later-in-cached_dev.patch b/for-test/for-5.3/reboot-deadlock/0003-bcache-acquire-bch_register_lock-later-in-cached_dev.patch new file mode 100644 index 0000000..9dcf0cb --- /dev/null +++ b/for-test/for-5.3/reboot-deadlock/0003-bcache-acquire-bch_register_lock-later-in-cached_dev.patch @@ -0,0 +1,39 @@ +From f5df2d368250a2604f6543b42bb31cfb13bb4408 Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Wed, 5 Jun 2019 16:37:50 +0800 +Subject: [PATCH 3/4] bcache: acquire bch_register_lock later in + cached_dev_free() + +This patch is unnecesary + + +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/super.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c +index 65ebca4446d9..a5e2f500d96d 100644 +--- a/drivers/md/bcache/super.c ++++ b/drivers/md/bcache/super.c +@@ -1223,8 +1223,6 @@ static void cached_dev_free(struct closure *cl) + { + struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl); + +- mutex_lock(&bch_register_lock); +- + if (test_and_clear_bit(BCACHE_DEV_WB_RUNNING, &dc->disk.flags)) + cancel_writeback_rate_update_dwork(dc); + +@@ -1235,6 +1233,8 @@ static void cached_dev_free(struct closure *cl) + if (!IS_ERR_OR_NULL(dc->status_update_thread)) + kthread_stop(dc->status_update_thread); + ++ mutex_lock(&bch_register_lock); ++ + if (atomic_read(&dc->running)) + bd_unlink_disk_holder(dc->bdev, dc->disk.disk); + bcache_device_free(&dc->disk); +-- +2.16.4 + |