]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: handle non-inode owners for rtrmap record checking
authorDarrick J. Wong <djwong@kernel.org>
Tue, 14 Jul 2026 06:06:43 +0000 (23:06 -0700)
committerCarlos Maiolino <cem@kernel.org>
Tue, 14 Jul 2026 09:01:47 +0000 (11:01 +0200)
LOLLM noticed that two helper functions in the rtrmapbt scrub code don't
actually handle non-inode owners correctly -- CoW staging extents and
rgsuperblock extents are not shareable, but they are mergeable.  Fix
these two helpers.

Cc: stable@vger.kernel.org # v6.14
Fixes: 2d9a3e98053e8c ("xfs: allow overlapping rtrmapbt records for shared data extents")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/scrub/rtrmap.c

index b3b2cf17ba2c088563f9a6c0641903511d3db3dc..564d19a97a2f8f6cd975be9e842d9f8a30a39b5e 100644 (file)
@@ -87,6 +87,9 @@ xchk_rtrmapbt_is_shareable(
                return false;
        if (irec->rm_flags & XFS_RMAP_UNWRITTEN)
                return false;
+       if (irec->rm_owner == XFS_RMAP_OWN_COW ||
+           irec->rm_owner == XFS_RMAP_OWN_FS)
+               return false;
        return true;
 }
 
@@ -146,6 +149,9 @@ xchk_rtrmap_mergeable(
                return false;
        if (r1->rm_flags != r2->rm_flags)
                return false;
+       if (r1->rm_owner == XFS_RMAP_OWN_COW ||
+           r1->rm_owner == XFS_RMAP_OWN_FS)
+               return true;
        return r1->rm_offset + r1->rm_blockcount == r2->rm_offset;
 }