]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: set dc->io_disable to true in conditional_stop_bcache_device()
authorColy Li <colyli@suse.de>
Thu, 3 May 2018 10:51:36 +0000 (18:51 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 3 May 2018 14:35:15 +0000 (08:35 -0600)
commitce3f924968bb6715fa61412315dddeb78a30bc25
tree22076d16824b546806ee8b76cddb7eef1533d57a
parent10a7de00c08c47d0179ca21e1c7e7caaa7b46146
bcache: set dc->io_disable to true in conditional_stop_bcache_device()

Commit 5b564f0f8801e ("bcache: add stop_when_cache_set_failed option to
backing device") adds stop_when_cache_set_failed option and stops bcache
device if stop_when_cache_set_failed is auto and there is dirty data on
broken cache device. There might exists a small time gap that the cache
set is released and set to NULL but bcache device is not released yet
(because they are released in parallel). During this time gap, dc->c is
NULL so CACHE_SET_IO_DISABLE won't be checked, and dc->io_disable is still
false, so new coming I/O requests will be accepted and directly go into
backing device as no cache set attached to. If there is dirty data on
cache device, this behavior may introduce potential inconsistent data.

This patch sets dc->io_disable to true before calling bcache_device_stop()
to make sure the backing device will reject new coming I/O request as
well, so even in the small time gap no I/O will directly go into backing
device to corrupt data consistency.

Fixes: 5b564f0f8801e ("bcache: add stop_when_cache_set_failed option to backing device")
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/super.c