diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-30 20:49:22 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 17:29:23 -0400 |
commit | 3793b3f91f88269ff8ad8ed2b95c6779415e7fd5 (patch) | |
tree | 1e2a3c75040f11853f37ccb5498a2912e6917824 /fs/bcachefs | |
parent | c387d84413711388a1bc5bf551c38f4b02529cc4 (diff) |
bcachefs: bch2_extent_merge() -> bch2_dev_rcu()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/extents.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index 6376440f6f30..46f8164b1a49 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -252,7 +252,6 @@ bool bch2_extent_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r) const union bch_extent_entry *en_r; struct extent_ptr_decoded lp, rp; bool use_right_ptr; - struct bch_dev *ca; en_l = l_ptrs.start; en_r = r_ptrs.start; @@ -283,8 +282,12 @@ bool bch2_extent_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r) return false; /* Extents may not straddle buckets: */ - ca = bch2_dev_bkey_exists(c, lp.ptr.dev); - if (PTR_BUCKET_NR(ca, &lp.ptr) != PTR_BUCKET_NR(ca, &rp.ptr)) + rcu_read_lock(); + struct bch_dev *ca = bch2_dev_rcu(c, lp.ptr.dev); + bool same_bucket = ca && PTR_BUCKET_NR(ca, &lp.ptr) == PTR_BUCKET_NR(ca, &rp.ptr); + rcu_read_unlock(); + + if (!same_bucket) return false; if (lp.has_ec != rp.has_ec || |