]> git.baikalelectronics.ru Git - kernel.git/commit
dm thin: stop no_space_timeout worker when switching to write-mode
authorHou Tao <houtao1@huawei.com>
Thu, 2 Aug 2018 08:18:24 +0000 (16:18 +0800)
committerMike Snitzer <snitzer@redhat.com>
Tue, 7 Aug 2018 18:30:29 +0000 (14:30 -0400)
commit2b1c9e9586739caf2a0ab16cd059bc5a017e457b
treeb60b709a7048a7864763f61b9e7628f51de8778a
parenta5663b1f424f43d882cdcd7e583317c84953658c
dm thin: stop no_space_timeout worker when switching to write-mode

Now both check_for_space() and do_no_space_timeout() will read & write
pool->pf.error_if_no_space.  If these functions run concurrently, as
shown in the following case, the default setting of "queue_if_no_space"
can get lost.

precondition:
    * error_if_no_space = false (aka "queue_if_no_space")
    * pool is in Out-of-Data-Space (OODS) mode
    * no_space_timeout worker has been queued

CPU 0:                          CPU 1:
// delete a thin device
process_delete_mesg()
// check_for_space() invoked by commit()
set_pool_mode(pool, PM_WRITE)
    pool->pf.error_if_no_space = \
     pt->requested_pf.error_if_no_space

// timeout, pool is still in OODS mode
do_no_space_timeout
    // "queue_if_no_space" config is lost
    pool->pf.error_if_no_space = true
    pool->pf.mode = new_mode

Fix it by stopping no_space_timeout worker when switching to write mode.

Fixes: 1134002b5055 ("dm thin: stay in out-of-data-space mode once no_space_timeout expires")
Cc: stable@vger.kernel.org
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-thin.c