]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: allow inodes with zero extents but nonzero nblocks
authorDarrick J. Wong <djwong@kernel.org>
Thu, 15 Aug 2024 18:48:54 +0000 (11:48 -0700)
committerChristoph Hellwig <hch@lst.de>
Sun, 22 Sep 2024 08:48:13 +0000 (10:48 +0200)
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 de321ad11a8a619058e9507e602f720cf2350c26..701086e538c4ba832e113f700775297c81f352bb 100644 (file)
@@ -651,9 +651,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;
 
@@ -757,6 +754,19 @@ xfs_dinode_verify(
                        return fa;
        }
 
+       /* metadata inodes containing btrees always have zero extent count */
+       if (flags2 & XFS_DIFLAG2_METADATA) {
+               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;
 }