yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-add-thread-pool-size-NUM-option.patch

22c213
From 3dbfb932288eb5a55dfdc0eebca7e4c7f0cf6f33 Mon Sep 17 00:00:00 2001
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
Date: Mon, 27 Jan 2020 19:02:22 +0100
22c213
Subject: [PATCH 111/116] virtiofsd: add --thread-pool-size=NUM option
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Message-id: <20200127190227.40942-108-dgilbert@redhat.com>
22c213
Patchwork-id: 93561
22c213
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 107/112] virtiofsd: add --thread-pool-size=NUM option
22c213
Bugzilla: 1694164
22c213
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
22c213
22c213
From: Stefan Hajnoczi <stefanha@redhat.com>
22c213
22c213
Add an option to control the size of the thread pool.  Requests are now
22c213
processed in parallel by default.
22c213
22c213
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
22c213
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
(cherry picked from commit 951b3120dbc971f08681e1d860360e4a1e638902)
22c213
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
22c213
---
22c213
 tools/virtiofsd/fuse_i.h        | 1 +
22c213
 tools/virtiofsd/fuse_lowlevel.c | 7 ++++++-
22c213
 tools/virtiofsd/fuse_virtio.c   | 5 +++--
22c213
 3 files changed, 10 insertions(+), 3 deletions(-)
22c213
22c213
diff --git a/tools/virtiofsd/fuse_i.h b/tools/virtiofsd/fuse_i.h
22c213
index 1447d86..4e47e58 100644
22c213
--- a/tools/virtiofsd/fuse_i.h
22c213
+++ b/tools/virtiofsd/fuse_i.h
22c213
@@ -72,6 +72,7 @@ struct fuse_session {
22c213
     int   vu_listen_fd;
22c213
     int   vu_socketfd;
22c213
     struct fv_VuDev *virtio_dev;
22c213
+    int thread_pool_size;
22c213
 };
22c213
 
22c213
 struct fuse_chan {
22c213
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
22c213
index 79a4031..de2e2e0 100644
22c213
--- a/tools/virtiofsd/fuse_lowlevel.c
22c213
+++ b/tools/virtiofsd/fuse_lowlevel.c
22c213
@@ -28,6 +28,7 @@
22c213
 #include <sys/file.h>
22c213
 #include <unistd.h>
22c213
 
22c213
+#define THREAD_POOL_SIZE 64
22c213
 
22c213
 #define OFFSET_MAX 0x7fffffffffffffffLL
22c213
 
22c213
@@ -2519,6 +2520,7 @@ static const struct fuse_opt fuse_ll_opts[] = {
22c213
     LL_OPTION("allow_root", deny_others, 1),
22c213
     LL_OPTION("--socket-path=%s", vu_socket_path, 0),
22c213
     LL_OPTION("--fd=%d", vu_listen_fd, 0),
22c213
+    LL_OPTION("--thread-pool-size=%d", thread_pool_size, 0),
22c213
     FUSE_OPT_END
22c213
 };
22c213
 
22c213
@@ -2537,7 +2539,9 @@ void fuse_lowlevel_help(void)
22c213
     printf(
22c213
         "    -o allow_root              allow access by root\n"
22c213
         "    --socket-path=PATH         path for the vhost-user socket\n"
22c213
-        "    --fd=FDNUM                 fd number of vhost-user socket\n");
22c213
+        "    --fd=FDNUM                 fd number of vhost-user socket\n"
22c213
+        "    --thread-pool-size=NUM     thread pool size limit (default %d)\n",
22c213
+        THREAD_POOL_SIZE);
22c213
 }
22c213
 
22c213
 void fuse_session_destroy(struct fuse_session *se)
22c213
@@ -2591,6 +2595,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
22c213
     }
22c213
     se->fd = -1;
22c213
     se->vu_listen_fd = -1;
22c213
+    se->thread_pool_size = THREAD_POOL_SIZE;
22c213
     se->conn.max_write = UINT_MAX;
22c213
     se->conn.max_readahead = UINT_MAX;
22c213
 
22c213
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
22c213
index 0dcf2ef..9f65823 100644
22c213
--- a/tools/virtiofsd/fuse_virtio.c
22c213
+++ b/tools/virtiofsd/fuse_virtio.c
22c213
@@ -572,10 +572,11 @@ static void *fv_queue_thread(void *opaque)
22c213
     struct fv_QueueInfo *qi = opaque;
22c213
     struct VuDev *dev = &qi->virtio_dev->dev;
22c213
     struct VuVirtq *q = vu_get_queue(dev, qi->qidx);
22c213
+    struct fuse_session *se = qi->virtio_dev->se;
22c213
     GThreadPool *pool;
22c213
 
22c213
-    pool = g_thread_pool_new(fv_queue_worker, qi, 1 /* TODO max_threads */,
22c213
-                             TRUE, NULL);
22c213
+    pool = g_thread_pool_new(fv_queue_worker, qi, se->thread_pool_size, TRUE,
22c213
+                             NULL);
22c213
     if (!pool) {
22c213
         fuse_log(FUSE_LOG_ERR, "%s: g_thread_pool_new failed\n", __func__);
22c213
         return NULL;
22c213
-- 
22c213
1.8.3.1
22c213