]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: hoist rmap record flag checks from scrub
authorDarrick J. Wong <djwong@kernel.org>
Wed, 31 May 2023 09:00:21 +0000 (11:00 +0200)
committerCarlos Maiolino <cem@kernel.org>
Fri, 9 Jun 2023 08:27:50 +0000 (10:27 +0200)
Source kernel commit: 7d7d6d2fd0444904f12e70d9c930556c4eb44337

Move the rmap record flag checks from xchk_rmapbt_rec into
xfs_rmap_check_irec so that they are applied everywhere.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_rmap.c

index a5b48f0ec241fce9726076d6736316117c60599a..4657d7da7ff3fd278ae2d5c11fedf7f7519bcd82 100644 (file)
@@ -211,6 +211,10 @@ xfs_rmap_check_irec(
        const struct xfs_rmap_irec      *irec)
 {
        struct xfs_mount                *mp = cur->bc_mp;
+       bool                            is_inode;
+       bool                            is_unwritten;
+       bool                            is_bmbt;
+       bool                            is_attr;
 
        if (irec->rm_blockcount == 0)
                return __this_address;
@@ -231,6 +235,24 @@ xfs_rmap_check_irec(
               irec->rm_owner >= XFS_RMAP_OWN_MIN)))
                return __this_address;
 
+       /* Check flags. */
+       is_inode = !XFS_RMAP_NON_INODE_OWNER(irec->rm_owner);
+       is_bmbt = irec->rm_flags & XFS_RMAP_BMBT_BLOCK;
+       is_attr = irec->rm_flags & XFS_RMAP_ATTR_FORK;
+       is_unwritten = irec->rm_flags & XFS_RMAP_UNWRITTEN;
+
+       if (is_bmbt && irec->rm_offset != 0)
+               return __this_address;
+
+       if (!is_inode && irec->rm_offset != 0)
+               return __this_address;
+
+       if (is_unwritten && (is_bmbt || !is_inode || is_attr))
+               return __this_address;
+
+       if (!is_inode && (is_bmbt || is_unwritten || is_attr))
+               return __this_address;
+
        return NULL;
 }