diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-02-18 23:15:32 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:08:35 +0200 |
commit | 237e80483a6466f3c1968c2a8bb115b3e24d951b (patch) | |
tree | 0c8a3b53e0a1e492ea5e64c33aff975cb8193d7f /fs/bcachefs/btree_cache.h | |
parent | bcachefs: Fix traversing to interior nodes (diff) | |
download | linux-237e80483a6466f3c1968c2a8bb115b3e24d951b.tar.xz linux-237e80483a6466f3c1968c2a8bb115b3e24d951b.zip |
bcachefs: introduce b->hash_val
This is partly prep work for introducing bch_btree_ptr_v2, but it'll
also be a bit of a performance boost by moving the full key out of the
hot part of struct btree.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_cache.h')
-rw-r--r-- | fs/bcachefs/btree_cache.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_cache.h b/fs/bcachefs/btree_cache.h index adacb0a06703..270f7f8fb140 100644 --- a/fs/bcachefs/btree_cache.h +++ b/fs/bcachefs/btree_cache.h @@ -35,13 +35,20 @@ void bch2_fs_btree_cache_exit(struct bch_fs *); int bch2_fs_btree_cache_init(struct bch_fs *); void bch2_fs_btree_cache_init_early(struct btree_cache *); -#define PTR_HASH(_k) *((u64 *) &bkey_i_to_btree_ptr_c(_k)->v) +static inline u64 btree_ptr_hash_val(const struct bkey_i *k) +{ + switch (k->k.type) { + case KEY_TYPE_btree_ptr: + return *((u64 *) bkey_i_to_btree_ptr_c(k)->v.start); + default: + return 0; + } +} /* is btree node in hash table? */ static inline bool btree_node_hashed(struct btree *b) { - return b->key.k.type == KEY_TYPE_btree_ptr && - PTR_HASH(&b->key); + return b->hash_val != 0; } #define for_each_cached_btree(_b, _c, _tbl, _iter, _pos) \ |