]>
Commit | Line | Data |
---|---|---|
bed0f502 GKH |
1 | From 75294442d896f2767be34f75aca7cc2b0d01301f Mon Sep 17 00:00:00 2001 |
2 | From: Hou Tao <houtao1@huawei.com> | |
3 | Date: Thu, 2 Aug 2018 16:18:24 +0800 | |
4 | Subject: dm thin: stop no_space_timeout worker when switching to write-mode | |
5 | ||
6 | From: Hou Tao <houtao1@huawei.com> | |
7 | ||
8 | commit 75294442d896f2767be34f75aca7cc2b0d01301f upstream. | |
9 | ||
10 | Now both check_for_space() and do_no_space_timeout() will read & write | |
11 | pool->pf.error_if_no_space. If these functions run concurrently, as | |
12 | shown in the following case, the default setting of "queue_if_no_space" | |
13 | can get lost. | |
14 | ||
15 | precondition: | |
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 | ||
20 | CPU 0: CPU 1: | |
21 | // delete a thin device | |
22 | process_delete_mesg() | |
23 | // check_for_space() invoked by commit() | |
24 | set_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 | ||
34 | Fix it by stopping no_space_timeout worker when switching to write mode. | |
35 | ||
36 | Fixes: bcc696fac11f ("dm thin: stay in out-of-data-space mode once no_space_timeout expires") | |
37 | Cc: stable@vger.kernel.org | |
38 | Signed-off-by: Hou Tao <houtao1@huawei.com> | |
39 | Signed-off-by: Mike Snitzer <snitzer@redhat.com> | |
40 | Signed-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); |