Skip to contentSkip to conversation

xfs: fix data fork format filtering during inode repair

PATCH In review Darrick J. Wong 2 participants 2 messages Jan 16, 2025 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix data fork format filtering during inode repair

From: Darrick J. Wong <[email protected]>

Coverity noticed that xrep_dinode_bad_metabt_fork never runs because XFS_DINODE_FMT_META_BTREE is always filtered out in the mode selection switch of xrep_dinode_check_dfork.

Metadata btrees are allowed only in the data forks of regular files, so add this case explicitly. I guess this got fubard during a refactoring prior to 6.13 and I didn't notice until now. :/

Coverity-id: 1617714

---
 fs/xfs/scrub/inode_repair.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
fs/xfs/scrub/inode_repair.c +10 -2
index c8d17dd4fc3246..4299063ffe8749 100644
@@ -1057,9 +1057,17 @@ xrep_dinode_check_dfork(
 			return true;
 		break;
 	case S_IFREG:
-		if (fmt == XFS_DINODE_FMT_LOCAL)
+		switch (fmt) {
+		case XFS_DINODE_FMT_LOCAL:
 			return true;
-		fallthrough;
+		case XFS_DINODE_FMT_EXTENTS:
+		case XFS_DINODE_FMT_BTREE:
+		case XFS_DINODE_FMT_META_BTREE:
+			break;
+		default:
+			return true;
+		}
+		break;
 	case S_IFLNK:
 	case S_IFDIR:
 		switch (fmt) {