Skip to contentSkip to conversation

xfs_scrub: fix spacemap scan for internal rt devices

PATCH In review Darrick J. Wong 3 participants 6 messages Jul 1 – Jul 8

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_scrub: fix spacemap scan for internal rt devices

From: Darrick J. Wong <[email protected]>

The scrub media scan on a filesystem with an internal rt volume still fails with:

 # xfs_scrub -dTvnx /mnt
 Phase 6: Verify data file integrity.
 Error: dev 7:0 rtgroup 1 fsmap: Invalid argument. (spacemap.c line 162)
 Error: dev 7:0 rtgroup 0 fsmap: Invalid argument. (spacemap.c line 162)
 Info: /mnt: Scrub aborted after phase 6. (xfs_scrub.c line 522)

(this was from xfs/586)

When I tried to add support for internal rt devices in commit 37591ef3f4f14c ("xfs_scrub: support internal RT device"), I forgot that fsmap reports physical offsets into the underlying block device, and therefore expects the query keys to reflect that. Put another way, to scan a single rtgroup, one must add @rtstart to the fmr_physical field of the query keys.

This hasn't been reported until now because we inadvertently also disabled spacemap scans of internal rt volumes until commit 3e4bb144f657b1 ("xfs_scrub: handle media scans of internal rt devices correctly").

Cc <[email protected]> # v6.15.0
Fixes 37591ef3f4f14c ("xfs_scrub: support internal RT device")

---
sorry, I missed this one earlier :(

---
 scrub/spacemap.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
scrub/spacemap.c +13 -0
index 45ac61d0942ccb..65d716374c9eb3 100644
@@ -148,6 +148,19 @@ scan_rtg_rmaps(
 	keys[1].fmr_offset = ULLONG_MAX;
 	keys[1].fmr_flags = UINT_MAX;
 
+	/*
+	 * fsmap for an internal rt volume treats physical ranges as offsets
+	 * into the underlying block device.  Shift the query range up by
+	 * @rtstart here to skip the synthetic "internal filesystem" fsmap.
+	 */
+	if (ctx->mnt.fsgeom.rtstart) {
+		uint64_t	offset = ctx->mnt.fsgeom.rtstart *
+					 ctx->mnt.fsgeom.blocksize;
+
+		keys[0].fmr_physical += offset;
+		keys[1].fmr_physical += offset;
+	}
+
 	if (sbx->aborted)
 		return;
 
#3 lore raw
Quoted 2 lines · Christoph Hellwig

Btw, the current xfsprogs for-next fails a lot of xfstests without this. So it would be great to get it in ASAP.

I'm assuming Andrey saw my most recent PRs:

3. [GIT PULL 3/3] xfs_scrub: codex-inspired bug fixes, part 5
- by Darrick J. Wong @ 2026-07-02 19:42 UTC [8%]

2. [GIT PULL 2/3] mkfs.xfs: codex-inspired bug fixes, part 2
- by Darrick J. Wong @ 2026-07-02 19:41 UTC [8%]

1. [GIT PULL 1/3] mkfs.xfs: codex-inspired bug fixes
- by Darrick J. Wong @ 2026-07-02 19:41 UTC [8%]

I promise not to send any more xfsprogs bugfixes until after 7.1 is tagged, to avoid holding up the release any further. :)

--D

#4 lore raw
Quoted 5 lines · Darrick J. Wong
Quoted 2 lines · Christoph Hellwig

Btw, the current xfsprogs for-next fails a lot of xfstests without this. So it would be great to get it in ASAP.

I'm assuming Andrey saw my most recent PRs:

Note that the failures are without any of the series, and none of the series seems to include this patch.

#5 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Darrick J. Wong
Quoted 2 lines · Christoph Hellwig

Btw, the current xfsprogs for-next fails a lot of xfstests without this. So it would be great to get it in ASAP.

I'm assuming Andrey saw my most recent PRs:

Note that the failures are without any of the series, and none of the series seems to include this patch.

I will squash it with the one from the branch (they're the same except added to different places). I was waiting for my testing to finish overnight, will send for-next update with this patch today.

Signature · 1 line
- Andrey