Skip to content

Commit 3793b3f

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_extent_merge() -> bch2_dev_rcu()
Signed-off-by: Kent Overstreet <[email protected]>
1 parent c387d84 commit 3793b3f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/bcachefs/extents.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ bool bch2_extent_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r)
252252
const union bch_extent_entry *en_r;
253253
struct extent_ptr_decoded lp, rp;
254254
bool use_right_ptr;
255-
struct bch_dev *ca;
256255

257256
en_l = l_ptrs.start;
258257
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)
283282
return false;
284283

285284
/* Extents may not straddle buckets: */
286-
ca = bch2_dev_bkey_exists(c, lp.ptr.dev);
287-
if (PTR_BUCKET_NR(ca, &lp.ptr) != PTR_BUCKET_NR(ca, &rp.ptr))
285+
rcu_read_lock();
286+
struct bch_dev *ca = bch2_dev_rcu(c, lp.ptr.dev);
287+
bool same_bucket = ca && PTR_BUCKET_NR(ca, &lp.ptr) == PTR_BUCKET_NR(ca, &rp.ptr);
288+
rcu_read_unlock();
289+
290+
if (!same_bucket)
288291
return false;
289292

290293
if (lp.has_ec != rp.has_ec ||

0 commit comments

Comments
 (0)