diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-30 15:37:25 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 17:29:23 -0400 |
commit | fa6cce09f070990dfe384ef4ddfefdea73970abe (patch) | |
tree | d5c5875d4a2ce1bcc8c423883cea18e97129e30b /fs/bcachefs/sb-members.h | |
parent | cb4d340a10295fcea7e4363f1b95c1a8c6c9bed4 (diff) |
bcachefs: bch2_dev_iterate()
New helper for getting refs to devices as we iterate.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/sb-members.h')
-rw-r--r-- | fs/bcachefs/sb-members.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/bcachefs/sb-members.h b/fs/bcachefs/sb-members.h index 503b56051d7e..d6d391dc21ca 100644 --- a/fs/bcachefs/sb-members.h +++ b/fs/bcachefs/sb-members.h @@ -262,6 +262,14 @@ static inline struct bch_dev *bch2_dev_bucket_tryget(struct bch_fs *c, struct bp return ca; } +static inline struct bch_dev *bch2_dev_iterate(struct bch_fs *c, struct bch_dev *ca, unsigned dev_idx) +{ + if (ca && ca->dev_idx == dev_idx) + return ca; + bch2_dev_put(ca); + return bch2_dev_tryget(c, dev_idx); +} + /* XXX kill, move to struct bch_fs */ static inline struct bch_devs_mask bch2_online_devs(struct bch_fs *c) { |