bcachefs: kill btree_path.idx
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
d7e14035a4
commit
398c98347d
@ -1324,8 +1324,6 @@ void bch2_path_put(struct btree_trans *trans, btree_path_idx_t path_idx, bool in
|
||||
{
|
||||
struct btree_path *path = trans->paths + path_idx, *dup;
|
||||
|
||||
EBUG_ON(path->idx != path_idx);
|
||||
|
||||
if (!__btree_path_put(path, intent))
|
||||
return;
|
||||
|
||||
@ -1352,8 +1350,6 @@ void bch2_path_put(struct btree_trans *trans, btree_path_idx_t path_idx, bool in
|
||||
static void bch2_path_put_nokeep(struct btree_trans *trans, btree_path_idx_t path,
|
||||
bool intent)
|
||||
{
|
||||
EBUG_ON(trans->paths[path].idx != path);
|
||||
|
||||
if (!__btree_path_put(trans->paths + path, intent))
|
||||
return;
|
||||
|
||||
@ -1542,7 +1538,6 @@ static inline btree_path_idx_t btree_path_alloc(struct btree_trans *trans,
|
||||
__set_bit(idx, trans->paths_allocated);
|
||||
|
||||
struct btree_path *path = &trans->paths[idx];
|
||||
path->idx = idx;
|
||||
path->ref = 0;
|
||||
path->intent_ref = 0;
|
||||
path->nodes_locked = 0;
|
||||
@ -3090,7 +3085,7 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans)
|
||||
|
||||
prt_printf(out, "%i %s\n", task ? task->pid : 0, trans->fn);
|
||||
|
||||
trans_for_each_path_safe(trans, path, idx) {
|
||||
trans_for_each_path(trans, path, idx) {
|
||||
if (!path->nodes_locked)
|
||||
continue;
|
||||
|
||||
|
@ -64,40 +64,24 @@ static inline void btree_trans_sort_paths(struct btree_trans *trans)
|
||||
}
|
||||
|
||||
static inline struct btree_path *
|
||||
__trans_next_path_safe(struct btree_trans *trans, unsigned *idx)
|
||||
__trans_next_path(struct btree_trans *trans, unsigned *idx)
|
||||
{
|
||||
*idx = find_next_bit(trans->paths_allocated, BTREE_ITER_MAX, *idx);
|
||||
if (*idx == BTREE_ITER_MAX)
|
||||
return NULL;
|
||||
|
||||
EBUG_ON(*idx > BTREE_ITER_MAX);
|
||||
return &trans->paths[*idx];
|
||||
return *idx < BTREE_ITER_MAX ? &trans->paths[*idx] : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* This version is intended to be safe for use on a btree_trans that is owned by
|
||||
* another thread, for bch2_btree_trans_to_text();
|
||||
*/
|
||||
#define trans_for_each_path_safe_from(_trans, _path, _idx, _start) \
|
||||
#define trans_for_each_path_from(_trans, _path, _idx, _start) \
|
||||
for (_idx = _start; \
|
||||
(_path = __trans_next_path_safe((_trans), &_idx)); \
|
||||
(_path = __trans_next_path((_trans), &_idx)); \
|
||||
_idx++)
|
||||
|
||||
#define trans_for_each_path_safe(_trans, _path, _idx) \
|
||||
trans_for_each_path_safe_from(_trans, _path, _idx, 1)
|
||||
|
||||
static inline struct btree_path *
|
||||
__trans_next_path(struct btree_trans *trans, unsigned *idx)
|
||||
{
|
||||
struct btree_path *path = __trans_next_path_safe(trans, idx);
|
||||
EBUG_ON(path && path->idx != *idx);
|
||||
return path;
|
||||
}
|
||||
|
||||
#define trans_for_each_path(_trans, _path, _iter) \
|
||||
for (_iter = 1; \
|
||||
(_path = __trans_next_path((_trans), &_iter)); \
|
||||
_iter++)
|
||||
#define trans_for_each_path(_trans, _path, _idx) \
|
||||
trans_for_each_path_from(_trans, _path, _idx, 1)
|
||||
|
||||
static inline struct btree_path *next_btree_path(struct btree_trans *trans, struct btree_path *path)
|
||||
{
|
||||
|
@ -302,7 +302,7 @@ next:
|
||||
|
||||
top = &g.g[g.nr - 1];
|
||||
|
||||
trans_for_each_path_safe_from(top->trans, path, path_idx, top->path_idx) {
|
||||
trans_for_each_path_from(top->trans, path, path_idx, top->path_idx) {
|
||||
if (!path->nodes_locked)
|
||||
continue;
|
||||
|
||||
|
@ -265,7 +265,6 @@ static inline int btree_node_lock(struct btree_trans *trans,
|
||||
int ret = 0;
|
||||
|
||||
EBUG_ON(level >= BTREE_MAX_DEPTH);
|
||||
EBUG_ON(!test_bit(path->idx, trans->paths_allocated));
|
||||
|
||||
if (likely(six_trylock_type(&b->lock, type)) ||
|
||||
btree_node_lock_increment(trans, b, level, (enum btree_node_locked_type) type) ||
|
||||
|
@ -225,7 +225,6 @@ enum btree_path_uptodate {
|
||||
typedef u16 btree_path_idx_t;
|
||||
|
||||
struct btree_path {
|
||||
btree_path_idx_t idx;
|
||||
btree_path_idx_t sorted_idx;
|
||||
u8 ref;
|
||||
u8 intent_ref;
|
||||
|
Loading…
x
Reference in New Issue
Block a user