Skip to content

Commit 8e3cc20

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_bkey_has_target() -> bch2_dev_rcu()
Signed-off-by: Kent Overstreet <[email protected]>
1 parent 8feecbe commit 8e3cc20

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/bcachefs/extents.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,14 +870,21 @@ const struct bch_extent_ptr *bch2_bkey_has_device_c(struct bkey_s_c k, unsigned
870870
bool bch2_bkey_has_target(struct bch_fs *c, struct bkey_s_c k, unsigned target)
871871
{
872872
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
873+
struct bch_dev *ca;
874+
bool ret = false;
873875

876+
rcu_read_lock();
874877
bkey_for_each_ptr(ptrs, ptr)
875878
if (bch2_dev_in_target(c, ptr->dev, target) &&
879+
(ca = bch2_dev_rcu(c, ptr->dev)) &&
876880
(!ptr->cached ||
877-
!dev_ptr_stale(bch2_dev_bkey_exists(c, ptr->dev), ptr)))
878-
return true;
881+
!dev_ptr_stale_rcu(ca, ptr))) {
882+
ret = true;
883+
break;
884+
}
885+
rcu_read_unlock();
879886

880-
return false;
887+
return ret;
881888
}
882889

883890
bool bch2_bkey_matches_ptr(struct bch_fs *c, struct bkey_s_c k,

0 commit comments

Comments
 (0)