]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.69/bcache-release-dc-writeback_lock-properly-in-bch_writeback_thread.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / bcache-release-dc-writeback_lock-properly-in-bch_writeback_thread.patch
1 From 3943b040f11ed0cc6d4585fd286a623ca8634547 Mon Sep 17 00:00:00 2001
2 From: Shan Hai <shan.hai@oracle.com>
3 Date: Thu, 23 Aug 2018 02:02:56 +0800
4 Subject: bcache: release dc->writeback_lock properly in bch_writeback_thread()
5
6 From: Shan Hai <shan.hai@oracle.com>
7
8 commit 3943b040f11ed0cc6d4585fd286a623ca8634547 upstream.
9
10 The writeback thread would exit with a lock held when the cache device
11 is detached via sysfs interface, fix it by releasing the held lock
12 before exiting the while-loop.
13
14 Fixes: fadd94e05c02 (bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set)
15 Signed-off-by: Shan Hai <shan.hai@oracle.com>
16 Signed-off-by: Coly Li <colyli@suse.de>
17 Tested-by: Shenghui Wang <shhuiw@foxmail.com>
18 Cc: stable@vger.kernel.org #4.17+
19 Signed-off-by: Jens Axboe <axboe@kernel.dk>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22 ---
23 drivers/md/bcache/writeback.c | 4 +++-
24 1 file changed, 3 insertions(+), 1 deletion(-)
25
26 --- a/drivers/md/bcache/writeback.c
27 +++ b/drivers/md/bcache/writeback.c
28 @@ -456,8 +456,10 @@ static int bch_writeback_thread(void *ar
29 * data on cache. BCACHE_DEV_DETACHING flag is set in
30 * bch_cached_dev_detach().
31 */
32 - if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags))
33 + if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) {
34 + up_write(&dc->writeback_lock);
35 break;
36 + }
37 }
38
39 up_write(&dc->writeback_lock);