Commit 5e31ee24 authored by Coly Li's avatar Coly Li Committed by Khalid Elmously

bcache: improve bcache_reboot()

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: default avatarColy Li <colyli@suse.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
(cherry picked from commit eb8cbb6d)
Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 19402747
...@@ -2106,10 +2106,19 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) ...@@ -2106,10 +2106,19 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
list_for_each_entry_safe(dc, tdc, &uncached_devices, list) list_for_each_entry_safe(dc, tdc, &uncached_devices, list)
bcache_device_stop(&dc->disk); 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? */ /* What's a condition variable? */
while (1) { 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) && stopped = list_empty(&bch_cache_sets) &&
list_empty(&uncached_devices); list_empty(&uncached_devices);
...@@ -2121,7 +2130,6 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) ...@@ -2121,7 +2130,6 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
mutex_unlock(&bch_register_lock); mutex_unlock(&bch_register_lock);
schedule_timeout(timeout); schedule_timeout(timeout);
mutex_lock(&bch_register_lock);
} }
finish_wait(&unregister_wait, &wait); finish_wait(&unregister_wait, &wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment