diff mbox series

[11/47] xfs: allow inodes with zero extents but nonzero nblocks

Message ID 170405015460.1815505.10885100965257102076.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [01/47] xfs: simplify the xfs_rmap_{alloc,free}_extent calling conventions | expand

Commit Message

Darrick J. Wong Dec. 27, 2023, 1:13 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

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>
---
 libxfs/xfs_inode_buf.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 9755ae33813..e7bf8ff7046 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -598,9 +598,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;
 
@@ -704,6 +701,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;
 }