diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-25 21:43:29 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:20 -0400 |
commit | 9ddffaf83b5ac7cf79917cfe9a1435cc07d071b6 (patch) | |
tree | 1272deac11ba66146fe35a131a127724034e4e6e /fs/bcachefs/alloc_foreground.h | |
parent | abe19d458e8fffbebacaad3aad64604d2819913a (diff) | |
download | linux-9ddffaf83b5ac7cf79917cfe9a1435cc07d071b6.tar.gz linux-9ddffaf83b5ac7cf79917cfe9a1435cc07d071b6.tar.bz2 linux-9ddffaf83b5ac7cf79917cfe9a1435cc07d071b6.zip |
bcachefs: Put open_buckets in a hashtable
This is so that the copygc code doesn't have to refer to
bucket_mark.owned_by_allocator - assisting in getting rid of the in
memory bucket array.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/alloc_foreground.h')
-rw-r--r-- | fs/bcachefs/alloc_foreground.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/bcachefs/alloc_foreground.h b/fs/bcachefs/alloc_foreground.h index 39d8ae5bbb96..d466bda9afc8 100644 --- a/fs/bcachefs/alloc_foreground.h +++ b/fs/bcachefs/alloc_foreground.h @@ -91,6 +91,30 @@ static inline void bch2_open_bucket_get(struct bch_fs *c, } } +static inline open_bucket_idx_t *open_bucket_hashslot(struct bch_fs *c, + unsigned dev, u64 bucket) +{ + return c->open_buckets_hash + + (jhash_3words(dev, bucket, bucket >> 32, 0) & + (OPEN_BUCKETS_COUNT - 1)); +} + +static inline bool bch2_bucket_is_open(struct bch_fs *c, unsigned dev, u64 bucket) +{ + open_bucket_idx_t slot = *open_bucket_hashslot(c, dev, bucket); + + while (slot) { + struct open_bucket *ob = &c->open_buckets[slot]; + + if (ob->dev == dev && ob->bucket == bucket) + return true; + + slot = ob->hash; + } + + return false; +} + int bch2_bucket_alloc_set(struct bch_fs *, struct open_buckets *, struct dev_stripe_state *, struct bch_devs_mask *, unsigned, unsigned *, bool *, enum alloc_reserve, |