bcachefs: bch2_dev_bucket_exists() uses bch2_dev_rcu()
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 1 May 2024 07:26:37 +0000 (03:26 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 8 May 2024 21:29:23 +0000 (17:29 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.h

index a75eba6d95860f38a290b106af2c05ea638645d3..5f42dc1e7fcc808abe89173394b1127c8c13e52e 100644 (file)
@@ -15,13 +15,11 @@ enum bkey_invalid_flags;
 
 static inline bool bch2_dev_bucket_exists(struct bch_fs *c, struct bpos pos)
 {
-       struct bch_dev *ca;
-
-       if (!bch2_dev_exists(c, pos.inode))
-               return false;
-
-       ca = bch2_dev_bkey_exists(c, pos.inode);
-       return bucket_valid(ca, pos.offset);
+       rcu_read_lock();
+       struct bch_dev *ca = bch2_dev_rcu(c, pos.inode);
+       bool ret = ca && bucket_valid(ca, pos.offset);
+       rcu_read_unlock();
+       return ret;
 }
 
 static inline u64 bucket_to_u64(struct bpos bucket)