Commit 398c9834 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: kill btree_path.idx

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent d7e14035
...@@ -1324,8 +1324,6 @@ void bch2_path_put(struct btree_trans *trans, btree_path_idx_t path_idx, bool in ...@@ -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; struct btree_path *path = trans->paths + path_idx, *dup;
EBUG_ON(path->idx != path_idx);
if (!__btree_path_put(path, intent)) if (!__btree_path_put(path, intent))
return; return;
...@@ -1352,8 +1350,6 @@ void bch2_path_put(struct btree_trans *trans, btree_path_idx_t path_idx, bool in ...@@ -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, static void bch2_path_put_nokeep(struct btree_trans *trans, btree_path_idx_t path,
bool intent) bool intent)
{ {
EBUG_ON(trans->paths[path].idx != path);
if (!__btree_path_put(trans->paths + path, intent)) if (!__btree_path_put(trans->paths + path, intent))
return; return;
...@@ -1542,7 +1538,6 @@ static inline btree_path_idx_t btree_path_alloc(struct btree_trans *trans, ...@@ -1542,7 +1538,6 @@ static inline btree_path_idx_t btree_path_alloc(struct btree_trans *trans,
__set_bit(idx, trans->paths_allocated); __set_bit(idx, trans->paths_allocated);
struct btree_path *path = &trans->paths[idx]; struct btree_path *path = &trans->paths[idx];
path->idx = idx;
path->ref = 0; path->ref = 0;
path->intent_ref = 0; path->intent_ref = 0;
path->nodes_locked = 0; path->nodes_locked = 0;
...@@ -3090,7 +3085,7 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans) ...@@ -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); 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) if (!path->nodes_locked)
continue; continue;
......
...@@ -64,40 +64,24 @@ static inline void btree_trans_sort_paths(struct btree_trans *trans) ...@@ -64,40 +64,24 @@ static inline void btree_trans_sort_paths(struct btree_trans *trans)
} }
static inline struct btree_path * 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); *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 *idx < BTREE_ITER_MAX ? &trans->paths[*idx] : NULL;
return &trans->paths[*idx];
} }
/* /*
* This version is intended to be safe for use on a btree_trans that is owned by * 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(); * 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; \ for (_idx = _start; \
(_path = __trans_next_path_safe((_trans), &_idx)); \ (_path = __trans_next_path((_trans), &_idx)); \
_idx++) _idx++)
#define trans_for_each_path_safe(_trans, _path, _idx) \ #define trans_for_each_path(_trans, _path, _idx) \
trans_for_each_path_safe_from(_trans, _path, _idx, 1) trans_for_each_path_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++)
static inline struct btree_path *next_btree_path(struct btree_trans *trans, struct btree_path *path) static inline struct btree_path *next_btree_path(struct btree_trans *trans, struct btree_path *path)
{ {
......
...@@ -302,7 +302,7 @@ int bch2_check_for_deadlock(struct btree_trans *trans, struct printbuf *cycle) ...@@ -302,7 +302,7 @@ int bch2_check_for_deadlock(struct btree_trans *trans, struct printbuf *cycle)
top = &g.g[g.nr - 1]; 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) if (!path->nodes_locked)
continue; continue;
......
...@@ -265,7 +265,6 @@ static inline int btree_node_lock(struct btree_trans *trans, ...@@ -265,7 +265,6 @@ static inline int btree_node_lock(struct btree_trans *trans,
int ret = 0; int ret = 0;
EBUG_ON(level >= BTREE_MAX_DEPTH); EBUG_ON(level >= BTREE_MAX_DEPTH);
EBUG_ON(!test_bit(path->idx, trans->paths_allocated));
if (likely(six_trylock_type(&b->lock, type)) || if (likely(six_trylock_type(&b->lock, type)) ||
btree_node_lock_increment(trans, b, level, (enum btree_node_locked_type) type) || btree_node_lock_increment(trans, b, level, (enum btree_node_locked_type) type) ||
......
...@@ -225,7 +225,6 @@ enum btree_path_uptodate { ...@@ -225,7 +225,6 @@ enum btree_path_uptodate {
typedef u16 btree_path_idx_t; typedef u16 btree_path_idx_t;
struct btree_path { struct btree_path {
btree_path_idx_t idx;
btree_path_idx_t sorted_idx; btree_path_idx_t sorted_idx;
u8 ref; u8 ref;
u8 intent_ref; u8 intent_ref;
......
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