]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
bcache: improve bcache_reboot()
authorColy Li <colyli@suse.de>
Wed, 7 Aug 2019 12:46:16 +0000 (14:46 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 13 Aug 2019 12:11:36 +0000 (14:11 +0200)
BugLink: https://bugs.launchpad.net/bugs/1784665
This patch tries to release mutex bch_register_lock early, to give
chance to stop cache set and bcache device early.

This patch also expends time out of stopping all bcache device from
2 seconds to 10 seconds, because stopping writeback rate update worker
may delay for 5 seconds, 2 seconds is not enough.

After this patch applied, stopping bcache devices during system reboot
or shutdown is very hard to be observed any more.

Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit eb8cbb6df38f6e5124a3d5f1f8a3dbf519537c60)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/md/bcache/super.c

index dcb0e3931baacf1ef2e86a6b18220f82d705a35a..442ad26e07b7a4ae762bb946084b240071c0c161 100644 (file)
@@ -2399,10 +2399,19 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
                list_for_each_entry_safe(dc, tdc, &uncached_devices, list)
                        bcache_device_stop(&dc->disk);
 
+               mutex_unlock(&bch_register_lock);
+
+               /*
+                * Give an early chance for other kthreads and
+                * kworkers to stop themselves
+                */
+               schedule();
+
                /* What's a condition variable? */
                while (1) {
-                       long timeout = start + 2 * HZ - jiffies;
+                       long timeout = start + 10 * HZ - jiffies;
 
+                       mutex_lock(&bch_register_lock);
                        stopped = list_empty(&bch_cache_sets) &&
                                list_empty(&uncached_devices);
 
@@ -2414,7 +2423,6 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
 
                        mutex_unlock(&bch_register_lock);
                        schedule_timeout(timeout);
-                       mutex_lock(&bch_register_lock);
                }
 
                finish_wait(&unregister_wait, &wait);