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