Commit 1aeed454 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Optimize memory accesses in bch2_btree_node_get()

This puts a load behind some branches before where it's used, so that it
can execute in parallel with other loads.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 6be1b6d9
......@@ -775,16 +775,17 @@ struct btree *bch2_btree_node_get(struct btree_trans *trans, struct btree_path *
EBUG_ON(level >= BTREE_MAX_DEPTH);
if (c->opts.btree_node_mem_ptr_optimization) {
b = btree_node_mem_ptr(k);
/*
* Check b->hash_val _before_ calling btree_node_lock() - this
* might not be the node we want anymore, and trying to lock the
* wrong node could cause an unneccessary transaction restart:
*/
if (b && b->hash_val == btree_ptr_hash_val(k))
b = btree_node_mem_ptr(k);
/*
* Check b->hash_val _before_ calling btree_node_lock() - this might not
* be the node we want anymore, and trying to lock the wrong node could
* cause an unneccessary transaction restart:
*/
if (likely(c->opts.btree_node_mem_ptr_optimization &&
b &&
b->hash_val == btree_ptr_hash_val(k)))
goto lock_node;
}
retry:
b = btree_cache_find(bc, k);
if (unlikely(!b)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment