Commit 4e3d1899 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Inline bch2_btree_path_traverse() fastpath

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 419fc65f
...@@ -962,8 +962,6 @@ static __always_inline int btree_path_down(struct btree_trans *trans, ...@@ -962,8 +962,6 @@ static __always_inline int btree_path_down(struct btree_trans *trans,
return ret; return ret;
} }
static int btree_path_traverse_one(struct btree_trans *, struct btree_path *,
unsigned, unsigned long);
static int bch2_btree_path_traverse_all(struct btree_trans *trans) static int bch2_btree_path_traverse_all(struct btree_trans *trans)
{ {
...@@ -1009,7 +1007,7 @@ static int bch2_btree_path_traverse_all(struct btree_trans *trans) ...@@ -1009,7 +1007,7 @@ static int bch2_btree_path_traverse_all(struct btree_trans *trans)
*/ */
if (path->uptodate) { if (path->uptodate) {
__btree_path_get(path, false); __btree_path_get(path, false);
ret = btree_path_traverse_one(trans, path, 0, _THIS_IP_); ret = bch2_btree_path_traverse_one(trans, path, 0, _THIS_IP_);
__btree_path_put(path, false); __btree_path_put(path, false);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart) || if (bch2_err_matches(ret, BCH_ERR_transaction_restart) ||
...@@ -1114,7 +1112,7 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans, ...@@ -1114,7 +1112,7 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans,
* On error, caller (peek_node()/peek_key()) must return NULL; the error is * On error, caller (peek_node()/peek_key()) must return NULL; the error is
* stashed in the iterator and returned from bch2_trans_exit(). * stashed in the iterator and returned from bch2_trans_exit().
*/ */
static int btree_path_traverse_one(struct btree_trans *trans, int bch2_btree_path_traverse_one(struct btree_trans *trans,
struct btree_path *path, struct btree_path *path,
unsigned flags, unsigned flags,
unsigned long trace_ip) unsigned long trace_ip)
...@@ -1181,26 +1179,6 @@ static int btree_path_traverse_one(struct btree_trans *trans, ...@@ -1181,26 +1179,6 @@ static int btree_path_traverse_one(struct btree_trans *trans,
return ret; return ret;
} }
int __must_check bch2_btree_path_traverse(struct btree_trans *trans,
struct btree_path *path, unsigned flags)
{
if (0 && IS_ENABLED(CONFIG_BCACHEFS_DEBUG)) {
unsigned restart_probability_bits = 4 << min(trans->restart_count, 32U);
u64 max = ~(~0ULL << restart_probability_bits);
if (!get_random_u32_below(max)) {
trace_and_count(trans->c, trans_restart_injected, trans, _RET_IP_);
return btree_trans_restart(trans, BCH_ERR_transaction_restart_fault_inject);
}
}
if (path->uptodate < BTREE_ITER_NEED_RELOCK)
return 0;
return bch2_trans_cond_resched(trans) ?:
btree_path_traverse_one(trans, path, flags, _RET_IP_);
}
static inline void btree_path_copy(struct btree_trans *trans, struct btree_path *dst, static inline void btree_path_copy(struct btree_trans *trans, struct btree_path *dst,
struct btree_path *src) struct btree_path *src)
{ {
......
...@@ -174,6 +174,18 @@ bch2_btree_path_set_pos(struct btree_trans *trans, ...@@ -174,6 +174,18 @@ bch2_btree_path_set_pos(struct btree_trans *trans,
: path; : path;
} }
int __must_check bch2_btree_path_traverse_one(struct btree_trans *, struct btree_path *,
unsigned, unsigned long);
static inline int __must_check bch2_btree_path_traverse(struct btree_trans *trans,
struct btree_path *path, unsigned flags)
{
if (path->uptodate < BTREE_ITER_NEED_RELOCK)
return 0;
return bch2_btree_path_traverse_one(trans, path, flags, _RET_IP_);
}
int __must_check bch2_btree_path_traverse(struct btree_trans *, int __must_check bch2_btree_path_traverse(struct btree_trans *,
struct btree_path *, unsigned); struct btree_path *, unsigned);
struct btree_path *bch2_path_get(struct btree_trans *, enum btree_id, struct bpos, struct btree_path *bch2_path_get(struct btree_trans *, enum btree_id, struct bpos,
......
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