Skip to content

Commit 7333c94

Browse files
author
Darrick J. Wong
committed
xfs: don't coalesce file mappings that cross rtgroup boundaries in scrub
The bmbt scrubber will combine file mappings if they are mergeable to reduce the number of cross-referencing checks. However, we shouldn't combine mappings that cross rt group boundaries because that will cause verifiers to trip incorrectly. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent d162491 commit 7333c94

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

fs/xfs/scrub/bmap.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,12 @@ xchk_bmap_iext_mapping(
834834
/* Are these two mappings contiguous with each other? */
835835
static inline bool
836836
xchk_are_bmaps_contiguous(
837+
const struct xchk_bmap_info *info,
837838
const struct xfs_bmbt_irec *b1,
838839
const struct xfs_bmbt_irec *b2)
839840
{
841+
struct xfs_mount *mp = info->sc->mp;
842+
840843
/* Don't try to combine unallocated mappings. */
841844
if (!xfs_bmap_is_real_extent(b1))
842845
return false;
@@ -850,6 +853,17 @@ xchk_are_bmaps_contiguous(
850853
return false;
851854
if (b1->br_state != b2->br_state)
852855
return false;
856+
857+
/*
858+
* Don't combine bmaps that would cross rtgroup boundaries. This is a
859+
* valid state, but if combined they will fail rtb extent checks.
860+
*/
861+
if (info->is_rt && xfs_has_rtgroups(mp)) {
862+
if (xfs_rtb_to_rgno(mp, b1->br_startblock) !=
863+
xfs_rtb_to_rgno(mp, b2->br_startblock))
864+
return false;
865+
}
866+
853867
return true;
854868
}
855869

@@ -887,7 +901,7 @@ xchk_bmap_iext_iter(
887901
* that we just read, if possible.
888902
*/
889903
while (xfs_iext_peek_next_extent(ifp, &info->icur, &got)) {
890-
if (!xchk_are_bmaps_contiguous(irec, &got))
904+
if (!xchk_are_bmaps_contiguous(info, irec, &got))
891905
break;
892906

893907
if (!xchk_bmap_iext_mapping(info, &got)) {

0 commit comments

Comments
 (0)