From 3e4bb144f657b17bae9fba224acc10afd8f32e50 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 24 Jun 2026 11:15:17 -0700 Subject: [PATCH] xfs_scrub: handle media scans of internal rt devices correctly Codex noticed media scans of internal rt devices don't work at all correctly. First, we fail to allocate a ctx->verify_disks[XFS_DEV_RT] for the internal rt section, and even if we did, phase 6 doesn't allocate media_verify_state.rvp[XFS_DEV_RT] if there's a media error on an internal rt volume, so we'll crash there too. Fix both issues to make it work properly. Cc: linux-xfs@vger.kernel.org # v6.15.0 Fixes: 37591ef3f4f14c ("xfs_scrub: support internal RT device") Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- scrub/phase1.c | 7 +++++-- scrub/phase6.c | 4 ++-- scrub/spacemap.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scrub/phase1.c b/scrub/phase1.c index 34a2b3aec..6ac59264b 100644 --- a/scrub/phase1.c +++ b/scrub/phase1.c @@ -101,7 +101,8 @@ scrub_cleanup( disk_close(ctx->verify_disks[XFS_DEV_DATA]); if (ctx->verify_disks[XFS_DEV_LOG]) disk_close(ctx->verify_disks[XFS_DEV_LOG]); - if (ctx->verify_disks[XFS_DEV_RT]) + if (ctx->verify_disks[XFS_DEV_RT] && + ctx->verify_disks[XFS_DEV_RT] != ctx->verify_disks[XFS_DEV_DATA]) disk_close(ctx->verify_disks[XFS_DEV_RT]); fshandle_destroy(); error = -xfd_close(&ctx->mnt); @@ -232,7 +233,9 @@ configure_xfs_verify_fallback( } } - if (ctx->fsinfo.fs_rt) { + if (ctx->mnt.fsgeom.rtstart) { + ctx->verify_disks[XFS_DEV_RT] = ctx->verify_disks[XFS_DEV_DATA]; + } else if (ctx->fsinfo.fs_rt || ctx->mnt.fsgeom.rtstart) { ctx->verify_disks[XFS_DEV_RT] = disk_open(ctx->fsinfo.fs_rt); if (!ctx->verify_disks[XFS_DEV_RT]) { str_error(ctx, ctx->mntpoint, diff --git a/scrub/phase6.c b/scrub/phase6.c index 2278ae5ad..aef817add 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -744,7 +744,7 @@ phase6_func( goto out_datapool; } } - if (ctx->fsinfo.fs_rt) { + if (ctx->fsinfo.fs_rt || ctx->mnt.fsgeom.rtstart) { ret = alloc_pool(ctx, &vs, XFS_DEV_RT); if (ret) { str_liberror(ctx, ret, @@ -843,7 +843,7 @@ phase6_estimate( * nr_threads appropriately to handle that many threads. */ *nr_threads = read_verify_nproc(ctx); - if (ctx->fsinfo.fs_rt) + if (ctx->fsinfo.fs_rt || ctx->mnt.fsgeom.rtstart) *nr_threads += read_verify_nproc(ctx); if (ctx->fsinfo.fs_log) *nr_threads += read_verify_nproc(ctx); diff --git a/scrub/spacemap.c b/scrub/spacemap.c index 1ee4d1946..8f595ad94 100644 --- a/scrub/spacemap.c +++ b/scrub/spacemap.c @@ -266,7 +266,7 @@ scrub_scan_all_spacemaps( break; } } - if (ctx->fsinfo.fs_rt) { + if (ctx->fsinfo.fs_rt || ctx->mnt.fsgeom.rtstart) { for (agno = 0; agno < ctx->mnt.fsgeom.rgcount; agno++) { ret = -workqueue_add(&wq, scan_rtg_rmaps, agno, &sbx); if (ret) { -- 2.47.3