yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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