cryptospore / rpms / qemu-kvm

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