]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - scrub/phase1.c
xfs_scrub: use datadev parallelization estimates for thread count
[thirdparty/xfsprogs-dev.git] / scrub / phase1.c
index 9702f8159a5493d6f343a6894e402bb1e492199c..6b472147f866386f17acb039ff4f25d6bae0d9eb 100644 (file)
@@ -25,6 +25,7 @@
 #include "common.h"
 #include "disk.h"
 #include "scrub.h"
+#include "repair.h"
 
 /* Phase 1: Find filesystem geometry (and clean up after) */
 
@@ -48,6 +49,7 @@ xfs_cleanup_fs(
 {
        int                     error;
 
+       xfs_action_lists_free(&ctx->action_lists);
        if (ctx->fshandle)
                free_handle(ctx->fshandle, ctx->fshandle_len);
        if (ctx->rtdev)
@@ -107,13 +109,6 @@ _("Must be root to run scrub."));
                return false;
        }
 
-       ctx->nr_io_threads = nproc;
-       if (verbose) {
-               fprintf(stdout, _("%s: using %d threads to scrub.\n"),
-                               ctx->mntpoint, scrub_nproc(ctx));
-               fflush(stdout);
-       }
-
        if (!platform_test_xfs_fd(ctx->mnt_fd)) {
                str_info(ctx, ctx->mntpoint,
 _("Does not appear to be an XFS filesystem!"));
@@ -138,6 +133,11 @@ _("Does not appear to be an XFS filesystem!"));
                return false;
        }
 
+       if (!xfs_action_lists_alloc(ctx->geo.agcount, &ctx->action_lists)) {
+               str_error(ctx, ctx->mntpoint, _("Not enough memory."));
+               return false;
+       }
+
        ctx->agblklog = log2_roundup(ctx->geo.agblocks);
        ctx->blocklog = highbit32(ctx->geo.blocksize);
        ctx->inodelog = highbit32(ctx->geo.inodesize);
@@ -186,6 +186,13 @@ _("Unable to find realtime device path."));
                return false;
        }
 
+       ctx->nr_io_threads = disk_heads(ctx->datadev);
+       if (verbose) {
+               fprintf(stdout, _("%s: using %d threads to scrub.\n"),
+                               ctx->mntpoint, scrub_nproc(ctx));
+               fflush(stdout);
+       }
+
        if (ctx->fsinfo.fs_log) {
                ctx->logdev = disk_open(ctx->fsinfo.fs_log);
                if (error) {