]> 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 87847259e37428449427f878f28930e84c710b25..6b472147f866386f17acb039ff4f25d6bae0d9eb 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2018 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include <unistd.h>
@@ -39,6 +25,7 @@
 #include "common.h"
 #include "disk.h"
 #include "scrub.h"
+#include "repair.h"
 
 /* Phase 1: Find filesystem geometry (and clean up after) */
 
@@ -62,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)
@@ -121,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!"));
@@ -152,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);
@@ -200,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) {