From: Tang Junhui Date: Mon, 8 Oct 2018 12:41:12 +0000 (+0800) Subject: bcache: correct dirty data statistics X-Git-Tag: v4.19.2~348 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e9f19efcb1ce58f2bac949f34dc91060e470472;p=thirdparty%2Fkernel%2Fstable.git bcache: correct dirty data statistics commit 2e17a262a2371d38d2ec03614a2675a32cef9912 upstream. When bcache device is clean, dirty keys may still exist after journal replay, so we need to count these dirty keys even device in clean status, otherwise after writeback, the amount of dirty data would be incorrect. Signed-off-by: Tang Junhui Cc: stable@vger.kernel.org Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 9a5f84d614da8..03bb5cee2b835 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1148,11 +1148,12 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c, } if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) { - bch_sectors_dirty_init(&dc->disk); atomic_set(&dc->has_dirty, 1); bch_writeback_queue(dc); } + bch_sectors_dirty_init(&dc->disk); + bch_cached_dev_run(dc); bcache_device_link(&dc->disk, c, "bdev"); atomic_inc(&c->attached_dev_nr);