]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_repair: phase6: scan longform entries before header check
authorBill O'Donnell <bodonnel@redhat.com>
Tue, 15 Apr 2025 18:48:49 +0000 (13:48 -0500)
committerAndrey Albershteyn <aalbersh@kernel.org>
Mon, 28 Apr 2025 11:02:20 +0000 (13:02 +0200)
commit140fd5b163577bd99e07adcdea7e08a99bccbccd
treea5ad41eeb0e57e85d3f40e40d3680b4d7ab7aab9
parent454fab69c484c24d8fb76ac3676553a54af381f7
xfs_repair: phase6: scan longform entries before header check

In longform_dir2_entry_check, if check_dir3_header() fails for v5
metadata, we immediately go to out_fix: and try to rebuild the
directory via longform_dir2_rebuild. But because we haven't yet
called longform_dir2_entry_check_data, the *hashtab used to rebuild
the directory is empty, which results in all existing entries
getting moved to lost+found, and an empty rebuilt directory. On top
of that, the empty directory is now short form, so its nlinks come
out wrong and this requires another repair run to fix.

Scan the entries before checking the header, so that we have a
decent chance of properly rebuilding the dir if the header is
corrupt, rather than orphaning all the entries and moving them to
lost+found.

Suggested-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
[aalbersh updated changelog as suggested by Eric Sandeen]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
repair/phase6.c