bcachefs: fix can_write_extent()

Failing to check the return value of bch2_dev_rcu(): we could
(technically) race with device removal.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2025-05-14 10:44:21 -04:00
parent c7378d0e5e
commit 648c1142c9

View file

@ -744,7 +744,9 @@ static int can_write_extent(struct bch_fs *c, struct data_update *m)
rcu_read_lock();
unsigned nr_replicas = 0, i;
for_each_set_bit(i, devs.d, BCH_SB_MEMBERS_MAX) {
struct bch_dev *ca = bch2_dev_rcu(c, i);
struct bch_dev *ca = bch2_dev_rcu_noerror(c, i);
if (!ca)
continue;
struct bch_dev_usage usage;
bch2_dev_usage_read_fast(ca, &usage);