diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-03 23:48:23 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 23:29:22 +0200 |
commit | 4cd91e2f87a6b1f28806fc0082a9b31ce23d28b8 (patch) | |
tree | 170aa4e9e2e77714fd4e8d9da990407c7581aaee /fs | |
parent | bcachefs: bch2_dev_tryget() (diff) | |
download | linux-4cd91e2f87a6b1f28806fc0082a9b31ce23d28b8.tar.xz linux-4cd91e2f87a6b1f28806fc0082a9b31ce23d28b8.zip |
bcachefs: Convert to bch2_dev_tryget_noerror()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/alloc_foreground.c | 15 | ||||
-rw-r--r-- | fs/bcachefs/chardev.c | 7 |
2 files changed, 4 insertions, 18 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 92cafde165c0..f54d90868314 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -717,25 +717,16 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans, struct bch_fs *c = trans->c; struct dev_alloc_list devs_sorted = bch2_dev_alloc_list(c, stripe, devs_may_alloc); - unsigned dev; - struct bch_dev *ca; int ret = -BCH_ERR_insufficient_devices; - unsigned i; BUG_ON(*nr_effective >= nr_replicas); - for (i = 0; i < devs_sorted.nr; i++) { + for (unsigned i = 0; i < devs_sorted.nr; i++) { struct bch_dev_usage usage; struct open_bucket *ob; - dev = devs_sorted.devs[i]; - - rcu_read_lock(); - ca = rcu_dereference(c->devs[dev]); - if (ca) - bch2_dev_get(ca); - rcu_read_unlock(); - + unsigned dev = devs_sorted.devs[i]; + struct bch_dev *ca = bch2_dev_tryget_noerror(c, dev); if (!ca) continue; diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index ed1fe771a426..9e54323f0f5f 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -32,12 +32,7 @@ static struct bch_dev *bch2_device_lookup(struct bch_fs *c, u64 dev, if (dev >= c->sb.nr_devices) return ERR_PTR(-EINVAL); - rcu_read_lock(); - ca = rcu_dereference(c->devs[dev]); - if (ca) - bch2_dev_get(ca); - rcu_read_unlock(); - + ca = bch2_dev_tryget_noerror(c, dev); if (!ca) return ERR_PTR(-EINVAL); } else { |