]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
virtiofsd: add --thread-pool-size=NUM option
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 1 Aug 2019 16:54:09 +0000 (17:54 +0100)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Thu, 23 Jan 2020 16:41:37 +0000 (16:41 +0000)
Add an option to control the size of the thread pool.  Requests are now
processed in parallel by default.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/fuse_i.h
tools/virtiofsd/fuse_lowlevel.c
tools/virtiofsd/fuse_virtio.c

index 1447d86866293df1d7db27f01afa66810ae35364..4e47e5880d9f01feabd5dde6f6c547f6c3a717f3 100644 (file)
@@ -72,6 +72,7 @@ struct fuse_session {
     int   vu_listen_fd;
     int   vu_socketfd;
     struct fv_VuDev *virtio_dev;
+    int thread_pool_size;
 };
 
 struct fuse_chan {
index 79a40312666007a7c2d91049ac3caa147d1e9e75..de2e2e0c658d2e34b7bf8358bc21f02473c63663 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/file.h>
 #include <unistd.h>
 
+#define THREAD_POOL_SIZE 64
 
 #define OFFSET_MAX 0x7fffffffffffffffLL
 
@@ -2519,6 +2520,7 @@ static const struct fuse_opt fuse_ll_opts[] = {
     LL_OPTION("allow_root", deny_others, 1),
     LL_OPTION("--socket-path=%s", vu_socket_path, 0),
     LL_OPTION("--fd=%d", vu_listen_fd, 0),
+    LL_OPTION("--thread-pool-size=%d", thread_pool_size, 0),
     FUSE_OPT_END
 };
 
@@ -2537,7 +2539,9 @@ void fuse_lowlevel_help(void)
     printf(
         "    -o allow_root              allow access by root\n"
         "    --socket-path=PATH         path for the vhost-user socket\n"
-        "    --fd=FDNUM                 fd number of vhost-user socket\n");
+        "    --fd=FDNUM                 fd number of vhost-user socket\n"
+        "    --thread-pool-size=NUM     thread pool size limit (default %d)\n",
+        THREAD_POOL_SIZE);
 }
 
 void fuse_session_destroy(struct fuse_session *se)
@@ -2591,6 +2595,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
     }
     se->fd = -1;
     se->vu_listen_fd = -1;
+    se->thread_pool_size = THREAD_POOL_SIZE;
     se->conn.max_write = UINT_MAX;
     se->conn.max_readahead = UINT_MAX;
 
index 0dcf2ef57a43bfa68c2301f7d068149152713bee..9f6582343c6b4867c8e92731195e833ec952f4f0 100644 (file)
@@ -572,10 +572,11 @@ static void *fv_queue_thread(void *opaque)
     struct fv_QueueInfo *qi = opaque;
     struct VuDev *dev = &qi->virtio_dev->dev;
     struct VuVirtq *q = vu_get_queue(dev, qi->qidx);
+    struct fuse_session *se = qi->virtio_dev->se;
     GThreadPool *pool;
 
-    pool = g_thread_pool_new(fv_queue_worker, qi, 1 /* TODO max_threads */,
-                             TRUE, NULL);
+    pool = g_thread_pool_new(fv_queue_worker, qi, se->thread_pool_size, TRUE,
+                             NULL);
     if (!pool) {
         fuse_log(FUSE_LOG_ERR, "%s: g_thread_pool_new failed\n", __func__);
         return NULL;