]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: fix media verification thread pool size calculations
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 1 Nov 2019 20:32:45 +0000 (16:32 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 1 Nov 2019 20:32:45 +0000 (16:32 -0400)
The read verifier pool deals with two different thread counts -- there's
the submitter thread count that enables us to perform per-thread verify
request aggregation, and then there's the io thread pool count which is
the maximum number of IO requests we want to send to the disk at any
given time.

The io thread pool count should be derived from disk_heads() but instead
we bungle it by measuring and modifying(!) the nproc global variable.
Fix the derivation to use global variables correctly.

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/read_verify.c

index cba1b2d41831d30217553627e50ddc02af32e7fb..a963a3fd2b90baf8e9f92e93aabb4381300d4fb6 100644 (file)
@@ -80,6 +80,7 @@ read_verify_pool_alloc(
        struct read_verify_pool         **prvp)
 {
        struct read_verify_pool         *rvp;
+       unsigned int                    verifier_threads = disk_heads(disk);
        int                             ret;
 
        /*
@@ -99,7 +100,7 @@ read_verify_pool_alloc(
                        RVP_IO_MAX_SIZE);
        if (ret)
                goto out_free;
-       ret = ptcounter_alloc(nproc, &rvp->verified_bytes);
+       ret = ptcounter_alloc(verifier_threads, &rvp->verified_bytes);
        if (ret)
                goto out_buf;
        rvp->miniosz = miniosz;
@@ -110,11 +111,8 @@ read_verify_pool_alloc(
                        &rvp->rvstate);
        if (ret)
                goto out_counter;
-       /* Run in the main thread if we only want one thread. */
-       if (nproc == 1)
-               nproc = 0;
        ret = workqueue_create(&rvp->wq, (struct xfs_mount *)rvp,
-                       disk_heads(disk));
+                       verifier_threads == 1 ? 0 : verifier_threads);
        if (ret)
                goto out_rvstate;
        *prvp = rvp;