]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
scrub: simplify verifier threads calculation
authorChristoph Hellwig <hch@lst.de>
Mon, 16 Mar 2026 20:53:41 +0000 (13:53 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 9 Apr 2026 22:30:19 +0000 (15:30 -0700)
Throwing all CPUs at verifying seems like a bad idea for foreground
scrub, as does abusing I/O opt/min as that says absolutely nothing
about parallelism.  I can't really think of a better way than manually
configuring this except maybe kernel hints.  But the current decisions
are not good defaults, and also are the only user of struct disk for
file systems using the kernel verify ioctl.

The best default seems to be 8, because verification speed increases
diminish above that level.  Note that background service mode now obeys
the thread count restrictions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
[djwong: rebase atop previous patches, leave disk_heads() alone]
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
scrub/phase6.c
scrub/read_verify.c
scrub/read_verify.h

index 9b99d041ed8bf2fd6cc83e2388b4374ada623287..266a2bf0e453ae49cf5ab803a1f8152f36a7645d 100644 (file)
@@ -889,11 +889,11 @@ phase6_estimate(
         * can contribute to the progress counter.  Hence we need to set
         * nr_threads appropriately to handle that many threads.
         */
-       *nr_threads = disk_heads(ctx->verify_disks[XFS_DEV_DATA]);
-       if (ctx->verify_disks[XFS_DEV_RT])
-               *nr_threads += disk_heads(ctx->verify_disks[XFS_DEV_RT]);
-       if (ctx->verify_disks[XFS_DEV_LOG])
-               *nr_threads += disk_heads(ctx->verify_disks[XFS_DEV_LOG]);
+       *nr_threads = read_verify_nproc(ctx);
+       if (ctx->fsinfo.fs_rt)
+               *nr_threads += read_verify_nproc(ctx);
+       if (ctx->fsinfo.fs_log)
+               *nr_threads += read_verify_nproc(ctx);
        *rshift = 20;
        return 0;
 }
index 9b692a923dfdf3f550408937bc90474c351eeffd..ba04ad3684ebd78dfdb5f6e23b11a1aa8ac59a73 100644 (file)
@@ -70,6 +70,22 @@ struct read_verify_pool {
        int                     runtime_error;
 };
 
+unsigned int
+read_verify_nproc(
+       struct scrub_ctx                *ctx)
+{
+       if (force_nr_threads)
+               return force_nr_threads;
+
+       /*
+        * Throwing all CPUs at verifying seems like a bad idea for foreground
+        * scrub, as does abusing I/O opt/min as that says absolutely nothing
+        * about parallelism.  The authors observed diminishing returns on
+        * verification speed past 8 IO threads, so that's the default.
+        */
+       return 8;
+}
+
 /*
  * Create a thread pool to run read verifiers.
  *
@@ -84,8 +100,8 @@ read_verify_pool_alloc(
        struct read_verify_pool         **prvp)
 {
        struct read_verify_pool         *rvp;
-       unsigned int                    verifier_threads =
-               disk_heads(ctx->verify_disks[XFS_DEV_DATA]);
+       const unsigned int              verifier_threads =
+               read_verify_nproc(ctx);
        int                             ret;
 
        if (rvp_io_max_size() % ctx->mnt.fsgeom.blocksize)
index e4b36f6aaa20e1b356f35f0b2715d5a1e8bf3a97..6a338abb896bc3cf578c52debc280317bc8eefc8 100644 (file)
@@ -33,4 +33,6 @@ bool try_read_verify_schedule_io(struct read_verify_schedule *rs,
 
 int read_verify_bytes(struct read_verify_pool *rvp, uint64_t *bytes);
 
+unsigned int read_verify_nproc(struct scrub_ctx *ctx);
+
 #endif /* XFS_SCRUB_READ_VERIFY_H_ */