xfs_repair: fix link counts update following repair of a bad block
PATCH 1/1 xfs_repair: fix link counts update following repair of a bad block
From: Bill O'Donnell <[email protected]>
Updating nlinks, following repair of a bad block needs a bit of work. In unique cases, 2 runs of xfs_repair is needed to adjust the count to the proper value. This patch modifies location of longform_dir2_entry_check, moving longform_dir2_entry_check_data to run after the check_dir3_header error check. This results in the hashtab to be correctly filled and those entries don't end up in lost+found, and nlinks is properly adjusted on the first xfs_repair pass.
--- repair/phase6.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
repair/phase6.c +4 -3
@@ -2404,6 +2404,10 @@ longform_dir2_entry_check(/* check v5 metadata */ if (xfs_has_crc (mp)) { +longform_dir2_entry_check_data (mp, ip, num_illegal, + need_dot, + irec, ino_offset, bp, hashtab, + &freetab, da_bno, fmt ==XFS_DIR2_FMT_BLOCK ); error =check_dir3_header (mp, bp, ino);if (error) { fixit++;
@@ -2416,9 +2420,6 @@ longform_dir2_entry_check( } } -longform_dir2_entry_check_data (mp, ip, num_illegal, need_dot, - irec, ino_offset, bp, hashtab, - &freetab, da_bno, fmt ==XFS_DIR2_FMT_BLOCK );if (fmt ==XFS_DIR2_FMT_BLOCK )break ;
Signature · 1 line
2.49.0
Quoted 22 lines · On 3/24/25 1:20 PM, [email protected] wrote:
From: Bill O'Donnell <[email protected]>
Updating nlinks, following repair of a bad block needs a bit of work. In unique cases, 2 runs of
xfs_repairis needed to adjust the count to the proper value. This patch modifies location oflongform_dir2_entry_check, movinglongform_dir2_entry_check_datato run after thecheck_dir3_headererror check. This results in the hashtab to be correctly filled and those entries don't end up in lost+found, and nlinks is properly adjusted on the firstxfs_repairpass.Suggested-by Eric Sandeen <[email protected]>Signed-off-by Bill O'Donnell <[email protected]>--- repair/phase6.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)repair/phase6.c +0
-0
repair/phase6.c longform_dir2_entry_check( · line 2413
Quoted 10 lines
repair/phase6.c +4
-0@@ -2404,6 +2404,10 @@ longform_dir2_entry_check(/* check v5 metadata */ if (xfs_has_crc (mp)) { +longform_dir2_entry_check_data (mp, ip, num_illegal, + need_dot, + irec, ino_offset, bp, hashtab, + &freetab, da_bno, fmt ==XFS_DIR2_FMT_BLOCK ); error =check_dir3_header (mp, bp, ino);if (error) { fixit++;
This change would mean that longform_dir2_entry_check_data will never run on V4 filesystems, so that's not correct.
I think we can approach my suggestions in 2 steps.
1) if longform_dir2_rebuild ends up with a shortform dir due to very few entries, I think it needs to add an extra ref at that point, as is done elsewhere for short form entries.
2) longform_dir2_entry_check() logic can be improved so that even if the header is bad, we still do directory block scanning via longform_dir2_entry_check_data so that longform_dir2_rebuild has something to work with.
-Eric
Quoted 10 lines
repair/phase6.c +0
-3@@ -2416,9 +2420,6 @@ longform_dir2_entry_check( } } -longform_dir2_entry_check_data (mp, ip, num_illegal, need_dot, - irec, ino_offset, bp, hashtab, - &freetab, da_bno, fmt ==XFS_DIR2_FMT_BLOCK );if (fmt ==XFS_DIR2_FMT_BLOCK )break ;