bcachefs: fsck: check_directory_structure runs in reverse order
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 16 Jun 2025 20:13:02 +0000 (16:13 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 16 Jun 2025 23:05:02 +0000 (19:05 -0400)
When we find a directory connectivity problem, we should do the repair
in the oldest snapshot that has the issue - so that we don't end up
duplicating work or making a real mess of things.

Oldest snapshot IDs have the highest integer value, so - just walk
inodes in reverse order.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fsck.c

index 6e64af4ccc36d791e4c45d6d5339e9db4d5a5e73..7414a16af99092ee99f0caf363c4856cde8d8db5 100644 (file)
@@ -2841,7 +2841,7 @@ fsck_err:
 int bch2_check_directory_structure(struct bch_fs *c)
 {
        int ret = bch2_trans_run(c,
-               for_each_btree_key_commit(trans, iter, BTREE_ID_inodes, POS_MIN,
+               for_each_btree_key_reverse_commit(trans, iter, BTREE_ID_inodes, POS_MIN,
                                          BTREE_ITER_intent|
                                          BTREE_ITER_prefetch|
                                          BTREE_ITER_all_snapshots, k,