bcache: recal cached_dev_sectors on detach
authorShenghui Wang <shhuiw@foxmail.com>
Mon, 8 Oct 2018 12:41:15 +0000 (20:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:23:22 +0000 (08:23 +0100)
[ Upstream commit 46010141da6677b81cc77f9b47f8ac62bd1cbfd3 ]

Recal cached_dev_sectors on cached_dev detached, as recal done on
cached_dev attached.

Update the cached_dev_sectors before bcache_device_detach called
as bcache_device_detach will set bcache_device->c to NULL.

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/bcache/super.c

index 1a270e2262f5276c1424987e94aeb354293c51be..690aeb09bbf554c07880aaa5ae9441c2519f6469 100644 (file)
@@ -905,6 +905,7 @@ static void cached_dev_detach_finish(struct work_struct *w)
        bch_write_bdev_super(dc, &cl);
        closure_sync(&cl);
 
+       calc_cached_dev_sectors(dc->disk.c);
        bcache_device_detach(&dc->disk);
        list_move(&dc->list, &uncached_devices);