Skip to contentSkip to conversation

bcachefs: Fix bch2_have_enough_devs() for BCH_SB_MEMBER_INVALID

PATCH New Kent Overstreet 1 participant 1 message Oct 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: Fix bch2_have_enough_devs() for BCH_SB_MEMBER_INVALID

This fixes a kasan splat in the ec device removal tests.

---
 fs/bcachefs/replicas.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/bcachefs/replicas.c +5 -0
index 797da1032318..477ef0997949 100644
@@ -821,6 +821,11 @@ bool bch2_have_enough_devs(struct bch_fs *c, struct bch_devs_mask devs,
 
 		rcu_read_lock();
 		for (unsigned i = 0; i < e->nr_devs; i++) {
+			if (e->devs[i] == BCH_SB_MEMBER_INVALID) {
+				nr_failed++;
+				continue;
+			}
+
 			nr_online += test_bit(e->devs[i], devs.d);
 
 			struct bch_dev *ca = bch2_dev_rcu_noerror(c, e->devs[i]);
Signature · 1 line
2.45.2