Commit 33aa419d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix __btree_path_traverse_all

The loop that traverses paths in traverse_all() needs to be a little bit
tricky, because traversing a path can cause other paths to be added (or
perhaps removed) at about the same position.

The old logic was buggy, replace it with simpler logic.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 4b59a319
......@@ -1462,17 +1462,17 @@ static int __btree_path_traverse_all(struct btree_trans *trans, int ret,
while (i < trans->nr_sorted) {
path = trans->paths + trans->sorted[i];
EBUG_ON(!(trans->paths_allocated & (1ULL << path->idx)));
ret = btree_path_traverse_one(trans, path, 0, _THIS_IP_);
if (ret)
goto retry_all;
EBUG_ON(!(trans->paths_allocated & (1ULL << path->idx)));
if (path->nodes_locked ||
!btree_path_node(path, path->level))
/*
* Traversing a path can cause another path to be added at about
* the same position:
*/
if (path->uptodate) {
ret = btree_path_traverse_one(trans, path, 0, _THIS_IP_);
if (ret)
goto retry_all;
} else {
i++;
}
}
/*
......
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