From: Kent Overstreet Date: Wed, 16 Feb 2022 08:13:36 +0000 (-0500) Subject: bcachefs: Fix __btree_path_traverse_all X-Git-Tag: v6.7-rc1~201^2~1141 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33aa419db96077993af90eddb49adac1270a96e0;p=thirdparty%2Fkernel%2Flinux.git 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: Kent Overstreet --- diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 7b54d662f4cbd..c6c1c9da45f15 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1462,17 +1462,17 @@ retry_all: 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++; + } } /*