• Hou Tao's avatar
    dm thin: stop no_space_timeout worker when switching to write-mode · 75294442
    Hou Tao authored
    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.
        * 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
    // check_for_space() invoked by commit()
    set_pool_mode(pool, PM_WRITE)
        pool->pf.error_if_no_space = \
    				// timeout, pool is still in OODS mode
    				    // "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: bcc696fa
     ("dm thin: stay in out-of-data-space mode once no_space_timeout expires")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
dm-thin.c 110 KB