From: Shenghui Wang <shh...@foxmail.com>

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 <shh...@foxmail.com>
Signed-off-by: Coly Li <col...@suse.de>
---
 drivers/md/bcache/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 4989c7d4d4d0..dc392a485269 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1008,6 +1008,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);
 
-- 
2.19.0

Reply via email to