bcachefs: bch2_trans_node_add no longer uses trans_for_each_path()
In the future we'll be making trans->paths resizable and potentially having _many_ more paths (for fsck); we need to start fixing algorithms that walk each path in a transaction where possible. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
24de63dacb
commit
f33600057f
@ -674,14 +674,22 @@ static void bch2_trans_revalidate_updates_in_node(struct btree_trans *trans, str
|
||||
* A btree node is being replaced - update the iterator to point to the new
|
||||
* node:
|
||||
*/
|
||||
void bch2_trans_node_add(struct btree_trans *trans, struct btree *b)
|
||||
void bch2_trans_node_add(struct btree_trans *trans,
|
||||
struct btree_path *path,
|
||||
struct btree *b)
|
||||
{
|
||||
struct btree_path *path;
|
||||
struct btree_path *prev;
|
||||
|
||||
trans_for_each_path(trans, path)
|
||||
if (path->uptodate == BTREE_ITER_UPTODATE &&
|
||||
!path->cached &&
|
||||
btree_path_pos_in_node(path, b)) {
|
||||
BUG_ON(!btree_path_pos_in_node(path, b));
|
||||
|
||||
while ((prev = prev_btree_path(trans, path)) &&
|
||||
btree_path_pos_in_node(prev, b))
|
||||
path = prev;
|
||||
|
||||
for (;
|
||||
path && btree_path_pos_in_node(path, b);
|
||||
path = next_btree_path(trans, path))
|
||||
if (path->uptodate == BTREE_ITER_UPTODATE && !path->cached) {
|
||||
enum btree_node_locked_type t =
|
||||
btree_lock_want(path, b->c.level);
|
||||
|
||||
|
@ -322,7 +322,7 @@ static inline void bch2_btree_path_downgrade(struct btree_trans *trans,
|
||||
|
||||
void bch2_trans_downgrade(struct btree_trans *);
|
||||
|
||||
void bch2_trans_node_add(struct btree_trans *trans, struct btree *);
|
||||
void bch2_trans_node_add(struct btree_trans *trans, struct btree_path *, struct btree *);
|
||||
void bch2_trans_node_reinit_iter(struct btree_trans *, struct btree *);
|
||||
|
||||
int __must_check __bch2_btree_iter_traverse(struct btree_iter *iter);
|
||||
|
@ -1601,10 +1601,10 @@ static int btree_split(struct btree_update *as, struct btree_trans *trans,
|
||||
bch2_btree_node_free_inmem(trans, path, b);
|
||||
|
||||
if (n3)
|
||||
bch2_trans_node_add(trans, n3);
|
||||
bch2_trans_node_add(trans, path, n3);
|
||||
if (n2)
|
||||
bch2_trans_node_add(trans, n2);
|
||||
bch2_trans_node_add(trans, n1);
|
||||
bch2_trans_node_add(trans, path2, n2);
|
||||
bch2_trans_node_add(trans, path1, n1);
|
||||
|
||||
if (n3)
|
||||
six_unlock_intent(&n3->c.lock);
|
||||
@ -1913,7 +1913,7 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
|
||||
bch2_btree_node_free_inmem(trans, path, b);
|
||||
bch2_btree_node_free_inmem(trans, sib_path, m);
|
||||
|
||||
bch2_trans_node_add(trans, n);
|
||||
bch2_trans_node_add(trans, path, n);
|
||||
|
||||
bch2_trans_verify_paths(trans);
|
||||
|
||||
@ -1985,7 +1985,7 @@ int bch2_btree_node_rewrite(struct btree_trans *trans,
|
||||
|
||||
bch2_btree_node_free_inmem(trans, iter->path, b);
|
||||
|
||||
bch2_trans_node_add(trans, n);
|
||||
bch2_trans_node_add(trans, iter->path, n);
|
||||
six_unlock_intent(&n->c.lock);
|
||||
|
||||
bch2_btree_update_done(as, trans);
|
||||
|
Loading…
x
Reference in New Issue
Block a user