Skip to content

Commit

Permalink
bcache: fixup init dirty data errors
Browse files Browse the repository at this point in the history
commit 7cc47e6 upstream.

We found that after long run, the dirty_data of the bcache device
will have errors. This error cannot be eliminated unless re-register.

We also found that reattach after detach, this error can accumulate.

In bch_sectors_dirty_init(), all inode <= d->id keys will be recounted
again. This is wrong, we only need to count the keys of the current
device.

Fixes: b144e45 ("bcache: make bch_sectors_dirty_init() to be multithreaded")
Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
Cc:  <stable@vger.kernel.org>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20231120052503.6122-6-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
zoumingzhe authored and gregkh committed Dec 3, 2023
1 parent 8ff2531 commit 19aff88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/md/bcache/writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,11 @@ void bch_sectors_dirty_init(struct bcache_device *d)
op.count = 0;

for_each_key_filter(&c->root->keys,
k, &iter, bch_ptr_invalid)
k, &iter, bch_ptr_invalid) {
if (KEY_INODE(k) != op.inode)
continue;
sectors_dirty_init_fn(&op.op, c->root, k);
}

rw_unlock(0, c->root);
return;
Expand Down

0 comments on commit 19aff88

Please sign in to comment.