]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: figure out how many threads we're going to need
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 2 Feb 2018 15:32:45 +0000 (09:32 -0600)
committerEric Sandeen <sandeen@redhat.com>
Fri, 2 Feb 2018 15:32:45 +0000 (09:32 -0600)
Create the plumbing to figure out how many threads we're going to want
to do all of our scrubbing.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/common.c
scrub/common.h
scrub/xfs_scrub.h

index 37ccd4a36e3f131176a7ff5a3b472cf9327ca0b9..05bb89b1de3d0b045b4bbc369c6c8736fede89c5 100644 (file)
@@ -168,3 +168,29 @@ no_prefix:
        *units = "";
        return number;
 }
+
+/* How many threads to kick off? */
+unsigned int
+scrub_nproc(
+       struct scrub_ctx        *ctx)
+{
+       if (nr_threads)
+               return nr_threads;
+       return ctx->nr_io_threads;
+}
+
+/*
+ * How many threads to kick off for a workqueue?  If we only want one
+ * thread, save ourselves the overhead and just run it in the main thread.
+ */
+unsigned int
+scrub_nproc_workqueue(
+       struct scrub_ctx        *ctx)
+{
+       unsigned int            x;
+
+       x = scrub_nproc(ctx);
+       if (x == 1)
+               x = 0;
+       return x;
+}
index e26e0e849ac0fb8ba508ad98745a2a77a0dea86c..4779dbdc5caccf326c7a06a9307f8aa2e8305edc 100644 (file)
@@ -61,5 +61,7 @@ debug_tweak_on(
 double timeval_subtract(struct timeval *tv1, struct timeval *tv2);
 double auto_space_units(unsigned long long kilobytes, char **units);
 double auto_units(unsigned long long number, char **units);
+unsigned int scrub_nproc(struct scrub_ctx *ctx);
+unsigned int scrub_nproc_workqueue(struct scrub_ctx *ctx);
 
 #endif /* XFS_SCRUB_COMMON_H_ */
index 51b8b7a44d9f2bfe6e91a6b42142dd7650a3a883..6d9f0c1e2d85b78e933c349caa6412067d03e25b 100644 (file)
@@ -54,6 +54,9 @@ struct scrub_ctx {
        /* How does the user want us to react to errors? */
        enum error_action       error_action;
 
+       /* Number of threads for metadata scrubbing */
+       unsigned int            nr_io_threads;
+
        /* Mutable scrub state; use lock. */
        pthread_mutex_t         lock;
        unsigned long long      max_errors;