]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.69/dm-thin-stop-no_space_timeout-worker-when-switching-to-write-mode.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / dm-thin-stop-no_space_timeout-worker-when-switching-to-write-mode.patch
CommitLineData
bed0f502
GKH
1From 75294442d896f2767be34f75aca7cc2b0d01301f Mon Sep 17 00:00:00 2001
2From: Hou Tao <houtao1@huawei.com>
3Date: Thu, 2 Aug 2018 16:18:24 +0800
4Subject: dm thin: stop no_space_timeout worker when switching to write-mode
5
6From: Hou Tao <houtao1@huawei.com>
7
8commit 75294442d896f2767be34f75aca7cc2b0d01301f upstream.
9
10Now both check_for_space() and do_no_space_timeout() will read & write
11pool->pf.error_if_no_space. If these functions run concurrently, as
12shown in the following case, the default setting of "queue_if_no_space"
13can get lost.
14
15precondition:
16 * error_if_no_space = false (aka "queue_if_no_space")
17 * pool is in Out-of-Data-Space (OODS) mode
18 * no_space_timeout worker has been queued
19
20CPU 0: CPU 1:
21// delete a thin device
22process_delete_mesg()
23// check_for_space() invoked by commit()
24set_pool_mode(pool, PM_WRITE)
25 pool->pf.error_if_no_space = \
26 pt->requested_pf.error_if_no_space
27
28 // timeout, pool is still in OODS mode
29 do_no_space_timeout
30 // "queue_if_no_space" config is lost
31 pool->pf.error_if_no_space = true
32 pool->pf.mode = new_mode
33
34Fix it by stopping no_space_timeout worker when switching to write mode.
35
36Fixes: bcc696fac11f ("dm thin: stay in out-of-data-space mode once no_space_timeout expires")
37Cc: stable@vger.kernel.org
38Signed-off-by: Hou Tao <houtao1@huawei.com>
39Signed-off-by: Mike Snitzer <snitzer@redhat.com>
40Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41
42---
43 drivers/md/dm-thin.c | 2 ++
44 1 file changed, 2 insertions(+)
45
46--- a/drivers/md/dm-thin.c
47+++ b/drivers/md/dm-thin.c
48@@ -2514,6 +2514,8 @@ static void set_pool_mode(struct pool *p
49 case PM_WRITE:
50 if (old_mode != new_mode)
51 notify_of_pool_mode_change(pool, "write");
52+ if (old_mode == PM_OUT_OF_DATA_SPACE)
53+ cancel_delayed_work_sync(&pool->no_space_timeout);
54 pool->out_of_data_space = false;
55 pool->pf.error_if_no_space = pt->requested_pf.error_if_no_space;
56 dm_pool_metadata_read_write(pool->pmd);