diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-03 23:39:16 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 23:29:22 +0200 |
commit | f295298b8c6413f0ed2a5a69dd7f32409cc54f1d (patch) | |
tree | a3266d3a851dad863746331a28400a86205331c2 /fs/bcachefs/sb-members.h | |
parent | bcachefs: bch2_print_allocator_stuck() (diff) | |
download | linux-f295298b8c6413f0ed2a5a69dd7f32409cc54f1d.tar.xz linux-f295298b8c6413f0ed2a5a69dd7f32409cc54f1d.zip |
bcachefs: New helpers for device refcounts
This will be used in the next patch for adding some new debug mode
asserts.
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 | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/fs/bcachefs/sb-members.h b/fs/bcachefs/sb-members.h index 53034cea5843..0aeb7285dc8c 100644 --- a/fs/bcachefs/sb-members.h +++ b/fs/bcachefs/sb-members.h @@ -105,14 +105,28 @@ static inline struct bch_dev *__bch2_next_dev(struct bch_fs *c, struct bch_dev * for (struct bch_dev *_ca = NULL; \ (_ca = __bch2_next_dev((_c), _ca, (_mask)));) -static inline struct bch_dev *bch2_get_next_dev(struct bch_fs *c, struct bch_dev *ca) +static inline void bch2_dev_get(struct bch_dev *ca) +{ + percpu_ref_get(&ca->ref); +} + +static inline void __bch2_dev_put(struct bch_dev *ca) +{ + percpu_ref_put(&ca->ref); +} + +static inline void bch2_dev_put(struct bch_dev *ca) { - rcu_read_lock(); if (ca) - percpu_ref_put(&ca->ref); + __bch2_dev_put(ca); +} +static inline struct bch_dev *bch2_get_next_dev(struct bch_fs *c, struct bch_dev *ca) +{ + rcu_read_lock(); + bch2_dev_put(ca); if ((ca = __bch2_next_dev(c, ca, NULL))) - percpu_ref_get(&ca->ref); + bch2_dev_get(ca); rcu_read_unlock(); return ca; |