Commit 255ebbbf authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch2_path_get() -> btree_path_idx_t

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5ce8b92d
......@@ -1547,10 +1547,10 @@ static inline struct btree_path *btree_path_alloc(struct btree_trans *trans,
return path;
}
struct btree_path *bch2_path_get(struct btree_trans *trans,
enum btree_id btree_id, struct bpos pos,
unsigned locks_want, unsigned level,
unsigned flags, unsigned long ip)
btree_path_idx_t bch2_path_get(struct btree_trans *trans,
enum btree_id btree_id, struct bpos pos,
unsigned locks_want, unsigned level,
unsigned flags, unsigned long ip)
{
struct btree_path *path, *path_pos = NULL;
bool cached = flags & BTREE_ITER_CACHED;
......@@ -1618,7 +1618,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans,
if (locks_want > path->locks_want)
bch2_btree_path_upgrade_noupgrade_sibs(trans, path, locks_want, NULL);
return path;
return path->idx;
}
struct bkey_s_c bch2_btree_path_peek_slot(struct btree_path *path, struct bkey *u)
......@@ -1928,7 +1928,7 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bpos
return bkey_s_c_null;
if (!iter->key_cache_path)
iter->key_cache_path = bch2_path_get(trans, iter->btree_id, pos,
iter->key_cache_path = trans->paths + bch2_path_get(trans, iter->btree_id, pos,
iter->flags & BTREE_ITER_INTENT, 0,
iter->flags|BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL,
......
......@@ -202,8 +202,8 @@ static inline int __must_check bch2_btree_path_traverse(struct btree_trans *tran
int __must_check bch2_btree_path_traverse(struct btree_trans *,
struct btree_path *, unsigned);
struct btree_path *bch2_path_get(struct btree_trans *, enum btree_id, struct bpos,
unsigned, unsigned, unsigned, unsigned long);
btree_path_idx_t bch2_path_get(struct btree_trans *, enum btree_id, struct bpos,
unsigned, unsigned, unsigned, unsigned long);
struct bkey_s_c bch2_btree_path_peek_slot(struct btree_path *, struct bkey *);
/*
......@@ -443,7 +443,7 @@ static inline void bch2_trans_iter_init_common(struct btree_trans *trans,
#ifdef CONFIG_BCACHEFS_DEBUG
iter->ip_allocated = ip;
#endif
iter->path = bch2_path_get(trans, btree_id, iter->pos,
iter->path = trans->paths + bch2_path_get(trans, btree_id, iter->pos,
locks_want, depth, flags, ip);
}
......
......@@ -222,6 +222,8 @@ enum btree_path_uptodate {
#define TRACK_PATH_ALLOCATED
#endif
typedef u16 btree_path_idx_t;
struct btree_path {
u8 idx;
u8 sorted_idx;
......
......@@ -344,16 +344,18 @@ static noinline int flush_new_cached_update(struct btree_trans *trans,
enum btree_update_flags flags,
unsigned long ip)
{
struct btree_path *btree_path;
struct bkey k;
int ret;
btree_path = bch2_path_get(trans, path->btree_id, path->pos, 1, 0,
BTREE_ITER_INTENT, _THIS_IP_);
ret = bch2_btree_path_traverse(trans, btree_path, 0);
btree_path_idx_t path_idx =
bch2_path_get(trans, path->btree_id, path->pos, 1, 0,
BTREE_ITER_INTENT, _THIS_IP_);
ret = bch2_btree_path_traverse(trans, trans->paths + path_idx, 0);
if (ret)
goto out;
struct btree_path *btree_path = trans->paths + path_idx;
/*
* The old key in the insert entry might actually refer to an existing
* key in the btree that has been deleted from cache and not yet
......@@ -467,7 +469,7 @@ static noinline int bch2_trans_update_get_key_cache(struct btree_trans *trans,
int ret;
if (!iter->key_cache_path)
iter->key_cache_path =
iter->key_cache_path = trans->paths +
bch2_path_get(trans, path->btree_id, path->pos, 1, 0,
BTREE_ITER_INTENT|
BTREE_ITER_CACHED, _THIS_IP_);
......
......@@ -36,7 +36,7 @@ static struct btree_path *get_unlocked_mut_path(struct btree_trans *trans,
{
struct btree_path *path;
path = bch2_path_get(trans, btree_id, pos, level + 1, level,
path = trans->paths + bch2_path_get(trans, btree_id, pos, level + 1, level,
BTREE_ITER_NOPRESERVE|
BTREE_ITER_INTENT, _RET_IP_);
path = bch2_btree_path_make_mut(trans, path, true, _RET_IP_);
......@@ -1795,7 +1795,7 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
? bpos_predecessor(b->data->min_key)
: bpos_successor(b->data->max_key);
sib_path = bch2_path_get(trans, path->btree_id, sib_pos,
sib_path = trans->paths + bch2_path_get(trans, path->btree_id, sib_pos,
U8_MAX, level, BTREE_ITER_INTENT, _THIS_IP_);
ret = bch2_btree_path_traverse(trans, sib_path, false);
if (ret)
......
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