xfs: update rmap to allow cow staging extents in the rt rmap
authorDarrick J. Wong <djwong@kernel.org>
Thu, 15 Aug 2024 18:58:26 +0000 (11:58 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 16 Aug 2024 21:57:43 +0000 (14:57 -0700)
Don't error out on CoW staging extent records when realtime reflink is
enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_rmap.c

index 751a7a91c4a9ec22ce658bac5f8d31224a89a1a5..7ce9b63a22c6471bfef07984b849714403cc3232 100644 (file)
@@ -275,6 +275,7 @@ xfs_rtrmap_check_irec(
        bool                            is_unwritten;
        bool                            is_bmbt;
        bool                            is_attr;
+       bool                            is_cow;
 
        if (irec->rm_blockcount == 0)
                return __this_address;
@@ -286,6 +287,12 @@ xfs_rtrmap_check_irec(
                        return __this_address;
                if (irec->rm_offset != 0)
                        return __this_address;
+       } else if (irec->rm_owner == XFS_RMAP_OWN_COW) {
+               if (!xfs_has_rtreflink(mp))
+                       return __this_address;
+               if (!xfs_verify_rgbext(rtg, irec->rm_startblock,
+                                           irec->rm_blockcount))
+                       return __this_address;
        } else {
                if (!xfs_verify_rgbext(rtg, irec->rm_startblock,
                                            irec->rm_blockcount))
@@ -302,8 +309,10 @@ xfs_rtrmap_check_irec(
        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;
+       is_cow = xfs_has_rtreflink(mp) &&
+                irec->rm_owner == XFS_RMAP_OWN_COW;
 
-       if (!is_inode && irec->rm_owner != XFS_RMAP_OWN_FS)
+       if (!is_inode && !is_cow && irec->rm_owner != XFS_RMAP_OWN_FS)
                return __this_address;
 
        if (!is_inode && irec->rm_offset != 0)
@@ -315,6 +324,9 @@ xfs_rtrmap_check_irec(
        if (is_unwritten && !is_inode)
                return __this_address;
 
+       if (is_unwritten && is_cow)
+               return __this_address;
+
        /* Check for a valid fork offset, if applicable. */
        if (is_inode &&
            !xfs_verify_fileext(mp, irec->rm_offset, irec->rm_blockcount))