Skip to contentSkip to conversation

bcache: fixup init dirty data errors

PATCH In review Mingzhe Zou 2 participants 2 messages Aug 24, 2023 bcache (block layer cache)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bcache: fixup init dirty data errors

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")
---
 drivers/md/bcache/writeback.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/writeback.c +4 -1
index 24c049067f61..4a1079da95b2 100644
@@ -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;
Signature · 1 line
2.17.1.windows.2
#1 lore raw
Quoted 4 lines

2023年8月24日 20:57,Mingzhe Zou <[email protected]> 写道:

Quoted 9 lines

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.

I will refine the commit log a bit.

Quoted 2 lines
Fixes b144e45fc576 ("bcache: make bch_sectors_dirty_init() to be multithreaded")

Added into my for-next directory.

Thanks for the fix up!

Coly Li

Quoted 24 lines

---
drivers/md/bcache/writeback.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/writeback.c +4 -1
index 24c049067f61..4a1079da95b2 100644
@@ -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;
Signature · 1 line
2.17.1.windows.2