diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-13 19:27:55 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:29 -0400 |
commit | 3e1547116fe70f49c88e1ee400966a1c7b1bec3a (patch) | |
tree | aed1c4cc0a205642478c18bbdd8525a17394fe34 /fs/bcachefs/alloc_foreground.c | |
parent | f13fd87a39225eae57d4ddf824a09acb1955abd1 (diff) |
bcachefs: x-macroize alloc_reserve enum
This makes an array of strings available, like our other enums.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_foreground.c')
-rw-r--r-- | fs/bcachefs/alloc_foreground.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index dc2f153f60c6..76a4b8029bdf 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -27,6 +27,13 @@ #include <linux/rculist.h> #include <linux/rcupdate.h> +const char * const bch2_alloc_reserves[] = { +#define x(t) #t, + BCH_ALLOC_RESERVES() +#undef x + NULL +}; + /* * Open buckets represent a bucket that's currently being allocated from. They * serve two purposes: @@ -168,10 +175,10 @@ long bch2_bucket_alloc_new_fs(struct bch_dev *ca) static inline unsigned open_buckets_reserved(enum alloc_reserve reserve) { switch (reserve) { - case RESERVE_BTREE: - case RESERVE_BTREE_MOVINGGC: + case RESERVE_btree: + case RESERVE_btree_movinggc: return 0; - case RESERVE_MOVINGGC: + case RESERVE_movinggc: return OPEN_BUCKETS_COUNT / 4; default: return OPEN_BUCKETS_COUNT / 2; @@ -219,17 +226,17 @@ struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca, c->blocked_allocate_open_bucket = local_clock(); spin_unlock(&c->freelist_lock); - trace_open_bucket_alloc_fail(ca, reserve); + trace_open_bucket_alloc_fail(ca, bch2_alloc_reserves[reserve]); return ERR_PTR(-OPEN_BUCKETS_EMPTY); } - if (likely(fifo_pop(&ca->free[RESERVE_NONE], b))) + if (likely(fifo_pop(&ca->free[RESERVE_none], b))) goto out; switch (reserve) { - case RESERVE_BTREE_MOVINGGC: - case RESERVE_MOVINGGC: - if (fifo_pop(&ca->free[RESERVE_MOVINGGC], b)) + case RESERVE_btree_movinggc: + case RESERVE_movinggc: + if (fifo_pop(&ca->free[RESERVE_movinggc], b)) goto out; break; default: @@ -244,7 +251,7 @@ struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca, spin_unlock(&c->freelist_lock); - trace_bucket_alloc_fail(ca, reserve); + trace_bucket_alloc_fail(ca, bch2_alloc_reserves[reserve]); return ERR_PTR(-FREELIST_EMPTY); out: verify_not_on_freelist(c, ca, b); @@ -282,7 +289,7 @@ out: bch2_wake_allocator(ca); - trace_bucket_alloc(ca, reserve); + trace_bucket_alloc(ca, bch2_alloc_reserves[reserve]); return ob; } |