]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
repair/prefetch.c: Create one workqueue with multiple workers for-next
authorChandan Babu R <chandanbabu@kernel.org>
Tue, 4 Nov 2025 09:14:37 +0000 (14:44 +0530)
committerAndrey Albershteyn <aalbersh@kernel.org>
Fri, 7 Nov 2025 12:17:04 +0000 (13:17 +0100)
When xfs_repair is executed with a non-zero value for ag_stride,
do_inode_prefetch() create multiple workqueues with each of them having just
one worker thread.

Since commit 12838bda12e669 ("libfrog: fix overly sleep workqueues"), a
workqueue can process multiple work items concurrently. Hence, this commit
replaces the above logic with just one workqueue having multiple workers.

Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
repair/prefetch.c

index 5ecf19ae9cb111d39edac1246c7feb512f02068d..8cd3416fa56847d5d4e106a98b9445857f3107b1 100644 (file)
@@ -1024,7 +1024,6 @@ do_inode_prefetch(
 {
        int                     i;
        struct workqueue        queue;
-       struct workqueue        *queues;
        int                     queues_started = 0;
 
        /*
@@ -1056,7 +1055,7 @@ do_inode_prefetch(
        /*
         * create one worker thread for each segment of the volume
         */
-       queues = malloc(thread_count * sizeof(struct workqueue));
+       create_work_queue(&queue, mp, thread_count);
        for (i = 0; i < thread_count; i++) {
                struct pf_work_args *wargs;
 
@@ -1067,8 +1066,7 @@ do_inode_prefetch(
                wargs->dirs_only = dirs_only;
                wargs->func = func;
 
-               create_work_queue(&queues[i], mp, 1);
-               queue_work(&queues[i], prefetch_ag_range_work, 0, wargs);
+               queue_work(&queue, prefetch_ag_range_work, 0, wargs);
                queues_started++;
 
                if (wargs->end_ag >= mp->m_sb.sb_agcount)
@@ -1078,9 +1076,7 @@ do_inode_prefetch(
        /*
         * wait for workers to complete
         */
-       for (i = 0; i < queues_started; i++)
-               destroy_work_queue(&queues[i]);
-       free(queues);
+       destroy_work_queue(&queue);
 }
 
 void