Commit 29aa78f1 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Split out __btree_path_up_until_good_node()

This breaks up btree_path_up_until_good_node() so that only the fastpath
gets inlined.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent b2f83e76
...@@ -994,14 +994,9 @@ static int bch2_btree_path_traverse_all(struct btree_trans *trans) ...@@ -994,14 +994,9 @@ static int bch2_btree_path_traverse_all(struct btree_trans *trans)
return ret; return ret;
} }
static inline bool btree_path_good_node(struct btree_trans *trans, static inline bool btree_path_check_pos_in_node(struct btree_path *path,
struct btree_path *path, unsigned l, int check_pos)
unsigned l, int check_pos)
{ {
if (!is_btree_node(path, l) ||
!bch2_btree_node_relock(trans, path, l))
return false;
if (check_pos < 0 && btree_path_pos_before_node(path, path->l[l].b)) if (check_pos < 0 && btree_path_pos_before_node(path, path->l[l].b))
return false; return false;
if (check_pos > 0 && btree_path_pos_after_node(path, path->l[l].b)) if (check_pos > 0 && btree_path_pos_after_node(path, path->l[l].b))
...@@ -1009,6 +1004,15 @@ static inline bool btree_path_good_node(struct btree_trans *trans, ...@@ -1009,6 +1004,15 @@ static inline bool btree_path_good_node(struct btree_trans *trans,
return true; return true;
} }
static inline bool btree_path_good_node(struct btree_trans *trans,
struct btree_path *path,
unsigned l, int check_pos)
{
return is_btree_node(path, l) &&
bch2_btree_node_relock(trans, path, l) &&
btree_path_check_pos_in_node(path, l, check_pos);
}
static void btree_path_set_level_down(struct btree_trans *trans, static void btree_path_set_level_down(struct btree_trans *trans,
struct btree_path *path, struct btree_path *path,
unsigned new_level) unsigned new_level)
...@@ -1025,9 +1029,9 @@ static void btree_path_set_level_down(struct btree_trans *trans, ...@@ -1025,9 +1029,9 @@ static void btree_path_set_level_down(struct btree_trans *trans,
bch2_btree_path_verify(trans, path); bch2_btree_path_verify(trans, path);
} }
static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans, static noinline unsigned __btree_path_up_until_good_node(struct btree_trans *trans,
struct btree_path *path, struct btree_path *path,
int check_pos) int check_pos)
{ {
unsigned i, l = path->level; unsigned i, l = path->level;
again: again:
...@@ -1048,6 +1052,16 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans, ...@@ -1048,6 +1052,16 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans,
return l; return l;
} }
static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans,
struct btree_path *path,
int check_pos)
{
return likely(btree_node_locked(path, path->level) &&
btree_path_check_pos_in_node(path, path->level, check_pos))
? path->level
: __btree_path_up_until_good_node(trans, path, check_pos);
}
/* /*
* This is the main state machine for walking down the btree - walks down to a * This is the main state machine for walking down the btree - walks down to a
* specified depth * specified depth
......
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