]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: handle media scans of internal rt devices correctly
authorDarrick J. Wong <djwong@kernel.org>
Wed, 24 Jun 2026 18:15:17 +0000 (11:15 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Thu, 25 Jun 2026 13:42:53 +0000 (15:42 +0200)
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" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/phase1.c
scrub/phase6.c
scrub/spacemap.c

index 34a2b3aec030ebd777a40ddcc5a61b171f9ced03..6ac59264b50bb7e590012364d4e0e975c60fc995 100644 (file)
@@ -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,
index 2278ae5ad3dfd7fba8a0e1f2be7a39f0eb4e0486..aef817add4157bd72fd95cb8b9a6aeff7530d2c7 100644 (file)
@@ -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);
index 1ee4d1946d3db7d3ebc89529b9b262ccaf1db446..8f595ad94c5991e9ce5ab3a1d74c3b10af23c5f4 100644 (file)
@@ -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) {