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,7 +1547,7 @@ static inline struct btree_path *btree_path_alloc(struct btree_trans *trans, ...@@ -1547,7 +1547,7 @@ static inline struct btree_path *btree_path_alloc(struct btree_trans *trans,
return path; return path;
} }
struct btree_path *bch2_path_get(struct btree_trans *trans, btree_path_idx_t bch2_path_get(struct btree_trans *trans,
enum btree_id btree_id, struct bpos pos, enum btree_id btree_id, struct bpos pos,
unsigned locks_want, unsigned level, unsigned locks_want, unsigned level,
unsigned flags, unsigned long ip) unsigned flags, unsigned long ip)
...@@ -1618,7 +1618,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans, ...@@ -1618,7 +1618,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans,
if (locks_want > path->locks_want) if (locks_want > path->locks_want)
bch2_btree_path_upgrade_noupgrade_sibs(trans, path, locks_want, NULL); 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) 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 ...@@ -1928,7 +1928,7 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bpos
return bkey_s_c_null; return bkey_s_c_null;
if (!iter->key_cache_path) 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_INTENT, 0,
iter->flags|BTREE_ITER_CACHED| iter->flags|BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL, BTREE_ITER_CACHED_NOFILL,
......
...@@ -202,7 +202,7 @@ static inline int __must_check bch2_btree_path_traverse(struct btree_trans *tran ...@@ -202,7 +202,7 @@ static inline int __must_check bch2_btree_path_traverse(struct btree_trans *tran
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, btree_path_idx_t bch2_path_get(struct btree_trans *, enum btree_id, struct bpos,
unsigned, unsigned, unsigned, unsigned long); unsigned, unsigned, unsigned, unsigned long);
struct bkey_s_c bch2_btree_path_peek_slot(struct btree_path *, struct bkey *); 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, ...@@ -443,7 +443,7 @@ static inline void bch2_trans_iter_init_common(struct btree_trans *trans,
#ifdef CONFIG_BCACHEFS_DEBUG #ifdef CONFIG_BCACHEFS_DEBUG
iter->ip_allocated = ip; iter->ip_allocated = ip;
#endif #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); locks_want, depth, flags, ip);
} }
......
...@@ -222,6 +222,8 @@ enum btree_path_uptodate { ...@@ -222,6 +222,8 @@ enum btree_path_uptodate {
#define TRACK_PATH_ALLOCATED #define TRACK_PATH_ALLOCATED
#endif #endif
typedef u16 btree_path_idx_t;
struct btree_path { struct btree_path {
u8 idx; u8 idx;
u8 sorted_idx; u8 sorted_idx;
......
...@@ -344,16 +344,18 @@ static noinline int flush_new_cached_update(struct btree_trans *trans, ...@@ -344,16 +344,18 @@ static noinline int flush_new_cached_update(struct btree_trans *trans,
enum btree_update_flags flags, enum btree_update_flags flags,
unsigned long ip) unsigned long ip)
{ {
struct btree_path *btree_path;
struct bkey k; struct bkey k;
int ret; int ret;
btree_path = bch2_path_get(trans, path->btree_id, path->pos, 1, 0, btree_path_idx_t path_idx =
bch2_path_get(trans, path->btree_id, path->pos, 1, 0,
BTREE_ITER_INTENT, _THIS_IP_); BTREE_ITER_INTENT, _THIS_IP_);
ret = bch2_btree_path_traverse(trans, btree_path, 0); ret = bch2_btree_path_traverse(trans, trans->paths + path_idx, 0);
if (ret) if (ret)
goto out; goto out;
struct btree_path *btree_path = trans->paths + path_idx;
/* /*
* The old key in the insert entry might actually refer to an existing * 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 * 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, ...@@ -467,7 +469,7 @@ static noinline int bch2_trans_update_get_key_cache(struct btree_trans *trans,
int ret; int ret;
if (!iter->key_cache_path) 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, bch2_path_get(trans, path->btree_id, path->pos, 1, 0,
BTREE_ITER_INTENT| BTREE_ITER_INTENT|
BTREE_ITER_CACHED, _THIS_IP_); BTREE_ITER_CACHED, _THIS_IP_);
......
...@@ -36,7 +36,7 @@ static struct btree_path *get_unlocked_mut_path(struct btree_trans *trans, ...@@ -36,7 +36,7 @@ static struct btree_path *get_unlocked_mut_path(struct btree_trans *trans,
{ {
struct btree_path *path; 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_NOPRESERVE|
BTREE_ITER_INTENT, _RET_IP_); BTREE_ITER_INTENT, _RET_IP_);
path = bch2_btree_path_make_mut(trans, path, true, _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, ...@@ -1795,7 +1795,7 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
? bpos_predecessor(b->data->min_key) ? bpos_predecessor(b->data->min_key)
: bpos_successor(b->data->max_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_); U8_MAX, level, BTREE_ITER_INTENT, _THIS_IP_);
ret = bch2_btree_path_traverse(trans, sib_path, false); ret = bch2_btree_path_traverse(trans, sib_path, false);
if (ret) 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