Commit 3a2d0259 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix bch2_dev_lookup() refcounting

bch2_dev_lookup() is supposed to take a ref on the device it returns, but
for_each_member_device() takes refs as it iterates,
for_each_member_device_rcu() does not.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 1267df40
...@@ -2004,13 +2004,9 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) ...@@ -2004,13 +2004,9 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
/* return with ref on ca->ref: */ /* return with ref on ca->ref: */
struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *name) struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *name)
{ {
rcu_read_lock(); for_each_member_device(c, ca)
for_each_member_device_rcu(c, ca, NULL) if (!strcmp(name, ca->name))
if (!strcmp(name, ca->name)) {
rcu_read_unlock();
return ca; return ca;
}
rcu_read_unlock();
return ERR_PTR(-BCH_ERR_ENOENT_dev_not_found); return ERR_PTR(-BCH_ERR_ENOENT_dev_not_found);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment