xfs: allow overlapping rtrmapbt records for shared data extents

Allow overlapping realtime reverse mapping records if they both describe
shared data extents and the fs supports reflink on the realtime volume.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Darrick J. Wong
2024-11-20 16:21:07 -08:00
parent 91683bb3f2
commit 2d9a3e9805

View File

@@ -78,6 +78,18 @@ struct xchk_rtrmap {
struct xfs_rmap_irec prev_rec;
};
static inline bool
xchk_rtrmapbt_is_shareable(
struct xfs_scrub *sc,
const struct xfs_rmap_irec *irec)
{
if (!xfs_has_rtreflink(sc->mp))
return false;
if (irec->rm_flags & XFS_RMAP_UNWRITTEN)
return false;
return true;
}
/* Flag failures for records that overlap but cannot. */
STATIC void
xchk_rtrmapbt_check_overlapping(
@@ -99,7 +111,10 @@ xchk_rtrmapbt_check_overlapping(
if (pnext <= irec->rm_startblock)
goto set_prev;
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
/* Overlap is only allowed if both records are data fork mappings. */
if (!xchk_rtrmapbt_is_shareable(bs->sc, &cr->overlap_rec) ||
!xchk_rtrmapbt_is_shareable(bs->sc, irec))
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
/* Save whichever rmap record extends furthest. */
inext = irec->rm_startblock + irec->rm_blockcount;