]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: allow inodes with zero extents but nonzero nblocks
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:54 +0000 (21:11 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 16 Jul 2024 22:50:42 +0000 (15:50 -0700)
Metadata inodes that store btrees will have zero extents and a nonzero
nblocks.  Adjust the inode verifier so that this combination is not
flagged.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_inode_buf.c

index d01ca89a9369a7ba4bbd287912be1c0f59f5ccfe..0466b8a41aaa7b4830520e7151b47bb029b8bbad 100644 (file)
@@ -634,9 +634,6 @@ xfs_dinode_verify(
        if (mode && nextents + naextents > nblocks)
                return __this_address;
 
-       if (nextents + naextents == 0 && nblocks != 0)
-               return __this_address;
-
        if (S_ISDIR(mode) && nextents > mp->m_dir_geo->max_extents)
                return __this_address;
 
@@ -740,6 +737,19 @@ xfs_dinode_verify(
                        return fa;
        }
 
+       /* metadata inodes containing btrees always have zero extent count */
+       if (flags2 & XFS_DIFLAG2_METADIR) {
+               switch (XFS_DFORK_FORMAT(dip, XFS_DATA_FORK)) {
+               case XFS_DINODE_FMT_RMAP:
+                       break;
+               default:
+                       if (nextents + naextents == 0 && nblocks != 0)
+                               return __this_address;
+                       break;
+               }
+       } else if (nextents + naextents == 0 && nblocks != 0)
+               return __this_address;
+
        return NULL;
 }