]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: fix di_metatype field of inodes that won't load
authorDarrick J. Wong <djwong@kernel.org>
Fri, 9 Aug 2024 19:51:19 +0000 (12:51 -0700)
committerChristoph Hellwig <hch@lst.de>
Sun, 22 Sep 2024 06:07:20 +0000 (08:07 +0200)
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/inode.c
fs/xfs/scrub/inode_repair.c

index 45222552a51ccb659781272af1ca690a1e363a02..07987a6569c43afdb87024beb949dbf8ea1b97bd 100644 (file)
@@ -443,9 +443,13 @@ xchk_dinode(
                break;
        case 2:
        case 3:
-               if (!(dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA)) &&
-                   dip->di_onlink != 0)
-                       xchk_ino_set_corrupt(sc, ino);
+               if (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA)) {
+                       if (be16_to_cpu(dip->di_metatype) >= XFS_METAFILE_MAX)
+                               xchk_ino_set_corrupt(sc, ino);
+               } else {
+                       if (dip->di_onlink != 0)
+                               xchk_ino_set_corrupt(sc, ino);
+               }
 
                if (dip->di_mode == 0 && sc->ip)
                        xchk_ino_set_corrupt(sc, ino);
index 7700fcd8170448d9533e018131fe4bf71086020e..b0808b54a512856ab8b6139e68b980cb0a53d29b 100644 (file)
@@ -526,8 +526,12 @@ xrep_dinode_nlinks(
                return;
        }
 
-       if (!(dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA)))
+       if (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA)) {
+               if (be16_to_cpu(dip->di_metatype) >= XFS_METAFILE_MAX)
+                       dip->di_metatype = cpu_to_be16(XFS_METAFILE_UNKNOWN);
+       } else {
                dip->di_onlink = 0;
+       }
 }
 
 /* Fix any conflicting flags that the verifiers complain about. */