Linux bcache driver list
 help / color / mirror / Atom feed
* [PATCH] bcache: fixup init dirty data errors
@ 2023-08-22 10:19 Mingzhe Zou
  2023-08-22 17:49 ` Coly Li
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mingzhe Zou @ 2023-08-22 10:19 UTC (permalink / raw)
  To: colyli, bcache, linux-bcache; +Cc: zoumingzhe, Mingzhe Zou

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: b144e45fc576 ("bcache: make bch_sectors_dirty_init() to be multithreaded")
Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
---
 drivers/md/bcache/writeback.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 24c049067f61..71d0dabcbf9d 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -983,6 +983,8 @@ void bch_sectors_dirty_init(struct bcache_device *d)
 	struct cache_set *c = d->c;
 	struct bch_dirty_init_state state;
 
+	atomic_long_set(&d->dirty_sectors, 0);
+
 	/* Just count root keys if no leaf node */
 	rw_lock(0, c->root, c->root->level);
 	if (c->root->level == 0) {
@@ -991,8 +993,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;
-- 
2.17.1.windows.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-08  3:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 10:19 [PATCH] bcache: fixup init dirty data errors Mingzhe Zou
2023-08-22 17:49 ` Coly Li
2023-08-24 12:49   ` 邹明哲
2023-08-24 16:36     ` Coly Li
2023-09-07 11:14       ` Eddie Chapman
2023-09-08  3:33         ` 邹明哲
2023-08-22 19:02 ` kernel test robot
2023-08-23  2:22 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox