diff options
author | 2025-05-14 10:44:21 -0400 | |
---|---|---|
committer | 2025-05-21 20:14:58 -0400 | |
commit | 648c1142c9f1ad914c9fd79cedbd6b92ac788cd6 (patch) | |
tree | 37a4a4d7006c0d55f95d8e8211d137c2322d2c7f | |
parent | bcachefs: Add tracepoint, counter for io_move_created_rebalance (diff) | |
download | wireguard-linux-648c1142c9f1ad914c9fd79cedbd6b92ac788cd6.tar.xz wireguard-linux-648c1142c9f1ad914c9fd79cedbd6b92ac788cd6.zip |
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>
-rw-r--r-- | fs/bcachefs/data_update.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index c39ea51e9e48..de096ca65b4b 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -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); |