]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
bcache: stop writeback kthread and kworker when bch_cached_dev_run() failed
authorColy Li <colyli@suse.de>
Fri, 28 Jun 2019 11:59:45 +0000 (19:59 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Jun 2019 13:39:16 +0000 (07:39 -0600)
In bch_cached_dev_attach() after bch_cached_dev_writeback_start()
called, the wrireback kthread and writeback rate update kworker of the
cached device are created, if the following bch_cached_dev_run()
failed, bch_cached_dev_attach() will return with -ENOMEM without
stopping the writeback related kthread and kworker.

This patch stops writeback kthread and writeback rate update kworker
before returning -ENOMEM if bch_cached_dev_run() returns error.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/super.c

index c4c4b2d99dc2137cd03bcd062eb0e4a374d3fd1b..791cb930b353257e6b9f622f2dfa292eb03a529d 100644 (file)
@@ -1189,6 +1189,14 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
        ret = bch_cached_dev_run(dc);
        if (ret && (ret != -EBUSY)) {
                up_write(&dc->writeback_lock);
+               /*
+                * bch_register_lock is held, bcache_device_stop() is not
+                * able to be directly called. The kthread and kworker
+                * created previously in bch_cached_dev_writeback_start()
+                * have to be stopped manually here.
+                */
+               kthread_stop(dc->writeback_thread);
+               cancel_writeback_rate_update_dwork(dc);
                pr_err("Couldn't run cached device %s",
                       dc->backing_dev_name);
                return ret;