diff options
-rw-r--r-- | fs/bcachefs/btree_iter.c | 12 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 6 | ||||
-rw-r--r-- | fs/bcachefs/btree_types.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_update.c | 12 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 4 |
5 files changed, 20 insertions, 16 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index f16fefbb6497..8662d396e57b 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -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, diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 3b981144e472..757354c53224 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -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); } diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index d129c0e468cc..19595a599c55 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -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; diff --git a/fs/bcachefs/btree_update.c b/fs/bcachefs/btree_update.c index ce3f0af5b1a0..7ee4d18af2d5 100644 --- a/fs/bcachefs/btree_update.c +++ b/fs/bcachefs/btree_update.c @@ -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_); diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 060fe357aa35..12a14d05c578 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -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) |