]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: implement background mode for phase 6
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 6 Nov 2019 22:27:06 +0000 (17:27 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 6 Nov 2019 22:27:06 +0000 (17:27 -0500)
Phase 6 doesn't implement background mode, which means that it doesn't
run in single-threaded mode with one -b and it doesn't sleep between
calls with multiple -b like every other phase does.  It also doesn't
restrict the amount of work per kernel call, which is a key part of
throttling.  Wire up the necessary pieces to make it behave like the man
page says it should.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/read_verify.c

index a963a3fd2b90baf8e9f92e93aabb4381300d4fb6..82605c8c10a49f32ec97a9fb0b2fd50cd0ae7f78 100644 (file)
  * because that's the biggest SCSI VERIFY(16) we dare to send.
  */
 #define RVP_IO_MAX_SIZE                (33554432)
-#define RVP_IO_MAX_SECTORS     (RVP_IO_MAX_SIZE >> BBSHIFT)
+
+/*
+ * If we're running in the background then we perform IO in 128k chunks
+ * to reduce the load on the IO subsystem.
+ */
+#define RVP_BACKGROUND_IO_MAX_SIZE     (131072)
+
+/* 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;
+}
 
 /* Tolerate 64k holes in adjacent read verify requests. */
 #define RVP_IO_BATCH_LOCALITY  (65536)
@@ -89,7 +101,7 @@ read_verify_pool_alloc(
         */
        if (miniosz % disk->d_lbasize)
                return EINVAL;
-       if (RVP_IO_MAX_SIZE % miniosz)
+       if (rvp_io_max_size() % miniosz)
                return EINVAL;
 
        rvp = calloc(1, sizeof(struct read_verify_pool));
@@ -97,7 +109,7 @@ read_verify_pool_alloc(
                return errno;
 
        ret = posix_memalign((void **)&rvp->readbuf, page_size,
-                       RVP_IO_MAX_SIZE);
+                       rvp_io_max_size());
        if (ret)
                goto out_free;
        ret = ptcounter_alloc(verifier_threads, &rvp->verified_bytes);
@@ -181,7 +193,7 @@ read_verify(
        if (rvp->runtime_error)
                return;
 
-       io_max_size = RVP_IO_MAX_SIZE;
+       io_max_size = rvp_io_max_size();
 
        while (rv->io_length > 0) {
                read_error = 0;
@@ -257,6 +269,7 @@ read_verify(
                        verified += sz;
                rv->io_start += sz;
                rv->io_length -= sz;
+               background_sleep();
        }
 
        free(rv);