]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: raise media verification IO limits
authorDarrick J. Wong <djwong@kernel.org>
Tue, 17 Mar 2026 16:58:55 +0000 (09:58 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 9 Apr 2026 22:30:19 +0000 (15:30 -0700)
To avoid starving other threads of disk IO resources, the read-verify
pool limits the size of verification IOs to limit bandwidth consumption,
and it is willing to over-verify some amount of unwritten media to
reduce the number of verification IO requests sent to the device.

However, these limits were set in 2018 when areal densities were lower
and disk bandwidth was more limited.  Increase them now to reduce scan
time on the author's system by 10% in foreground and 50% in background
mode.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/read_verify.c

index 01a3a8859c5fa868fc2889f384a88367e0e49eb5..7dd588c1482af5229259c4e632298b17bff4e456 100644 (file)
@@ -10,6 +10,7 @@
 #include "libfrog/workqueue.h"
 #include "libfrog/paths.h"
 #include "libfrog/bitmap.h"
+#include "libfrog/convert.h"
 #include "xfs_scrub.h"
 #include "common.h"
 #include "counter.h"
  */
 
 /* Perform all verification IO in 32M chunks. */
-#define RVP_IO_MAX_SIZE                (33554432)
+#define RVP_IO_MAX_SIZE                        MEGABYTES(32)
 
 /*
- * If we're running in the background then we perform IO in 128k chunks
+ * If we're running in the background then we perform IO in 256k chunks
  * to reduce the load on the IO subsystem.
  */
-#define RVP_BACKGROUND_IO_MAX_SIZE     (131072)
+#define RVP_BG_IO_MAX_SIZE             KILOBYTES(256)
 
 /* What's the real maximum IO size? */
 static inline unsigned int
 rvp_io_max_size(void)
 {
-       return bg_mode > 0 ? RVP_BACKGROUND_IO_MAX_SIZE : RVP_IO_MAX_SIZE;
+       return bg_mode > 0 ? RVP_BG_IO_MAX_SIZE : RVP_IO_MAX_SIZE;
 }
 
-/* Tolerate 64k holes in adjacent read verify requests. */
-#define RVP_IO_BATCH_LOCALITY  (65536)
+/* Tolerate 2M holes in adjacent read verify requests. */
+#define RVP_IO_BATCH_LOCALITY          MEGABYTES(2)
+
+/*
+ * Tolerate 256k holes in adjacent read verify requests when running in the
+ * background.
+ */
+#define RVP_BG_IO_BATCH_LOCALITY       KILOBYTES(256)
+
+/* How many holes are we willing to verify to reduce IO count? */
+static inline unsigned int
+rvp_io_batch_locality(void)
+{
+       return bg_mode > 0 ? RVP_BG_IO_BATCH_LOCALITY : RVP_IO_BATCH_LOCALITY;
+}
 
 struct read_verify {
        uint64_t                io_start;       /* bytes */
@@ -500,6 +514,7 @@ try_read_verify_schedule_io(
 {
        uint64_t                        req_end;
        uint64_t                        rv_end;
+       const unsigned int              locality = rvp_io_batch_locality();
 
        assert(rvp->readbuf);
 
@@ -525,9 +540,9 @@ try_read_verify_schedule_io(
         * we can combine them.
         */
        if (rs->rvp == rvp && rs->io_length > 0 &&
-           ((start >= rs->io_start && start <= rv_end + RVP_IO_BATCH_LOCALITY) ||
+           ((start >= rs->io_start && start <= rv_end + locality) ||
             (rs->io_start >= start &&
-             rs->io_start <= req_end + RVP_IO_BATCH_LOCALITY))) {
+             rs->io_start <= req_end + locality))) {
                rs->io_start = min(rs->io_start, start);
                rs->io_length = max(req_end, rv_end) - rs->io_start;