From 237e80483a6466f3c1968c2a8bb115b3e24d951b Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 18 Feb 2020 17:15:32 -0500 Subject: 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 Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_cache.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'fs/bcachefs/btree_cache.h') 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) \ -- cgit v1.2.3