xfs: fix data fork format filtering during inode repair
authorDarrick J. Wong <djwong@kernel.org>
Mon, 3 Feb 2025 00:50:14 +0000 (16:50 -0800)
committerCarlos Maiolino <cem@kernel.org>
Fri, 14 Feb 2025 08:40:24 +0000 (09:40 +0100)
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
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/scrub/inode_repair.c

index 2f641b6d663eb2b8d231a80265879c08df6be7a5..13ff1c933cb8f97e07a4509177e8ddd6bd311bba 100644 (file)
@@ -1055,9 +1055,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) {