Skip to content

Commit 5dab2da

Browse files
author
Darrick J. Wong
committed
xfs: fix di_metatype field of inodes that won't load
Make sure that the di_metatype field is at least set plausibly so that later scrubbers could set the real type. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent aec2eb7 commit 5dab2da

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

fs/xfs/scrub/inode.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,13 @@ xchk_dinode(
443443
break;
444444
case 2:
445445
case 3:
446-
if (!xfs_dinode_is_metadir(dip) && dip->di_metatype)
447-
xchk_ino_set_corrupt(sc, ino);
446+
if (xfs_dinode_is_metadir(dip)) {
447+
if (be16_to_cpu(dip->di_metatype) >= XFS_METAFILE_MAX)
448+
xchk_ino_set_corrupt(sc, ino);
449+
} else {
450+
if (dip->di_metatype != 0)
451+
xchk_ino_set_corrupt(sc, ino);
452+
}
448453

449454
if (dip->di_mode == 0 && sc->ip)
450455
xchk_ino_set_corrupt(sc, ino);

fs/xfs/scrub/inode_repair.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,12 @@ xrep_dinode_nlinks(
526526
return;
527527
}
528528

529-
if (!xfs_dinode_is_metadir(dip))
529+
if (xfs_dinode_is_metadir(dip)) {
530+
if (be16_to_cpu(dip->di_metatype) >= XFS_METAFILE_MAX)
531+
dip->di_metatype = cpu_to_be16(XFS_METAFILE_UNKNOWN);
532+
} else {
530533
dip->di_metatype = 0;
534+
}
531535
}
532536

533537
/* Fix any conflicting flags that the verifiers complain about. */

0 commit comments

Comments
 (0)