[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 105/109] virtiofsd: add --thread-pool-size=NUM option
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH v2 105/109] virtiofsd: add --thread-pool-size=NUM option |
Date: |
Tue, 21 Jan 2020 12:24:29 +0000 |
From: Stefan Hajnoczi <address@hidden>
Add an option to control the size of the thread pool. Requests are now
processed in parallel by default.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
---
tools/virtiofsd/fuse_i.h | 1 +
tools/virtiofsd/fuse_lowlevel.c | 7 ++++++-
tools/virtiofsd/fuse_virtio.c | 5 +++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/tools/virtiofsd/fuse_i.h b/tools/virtiofsd/fuse_i.h
index 1447d86866..4e47e5880d 100644
--- a/tools/virtiofsd/fuse_i.h
+++ b/tools/virtiofsd/fuse_i.h
@@ -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 {
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
index 8ae45d9c58..2ce3e739fd 100644
--- a/tools/virtiofsd/fuse_lowlevel.c
+++ b/tools/virtiofsd/fuse_lowlevel.c
@@ -27,6 +27,7 @@
#include <sys/file.h>
#include <unistd.h>
+#define THREAD_POOL_SIZE 64
#define OFFSET_MAX 0x7fffffffffffffffLL
@@ -2521,6 +2522,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
};
@@ -2541,7 +2543,9 @@ void fuse_lowlevel_help(void)
" -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"
- " -o auto_unmount auto unmount on process
termination\n");
+ " -o auto_unmount auto unmount on process termination\n"
+ " --thread-pool-size=NUM thread pool size limit (default %d)\n",
+ THREAD_POOL_SIZE);
}
void fuse_session_destroy(struct fuse_session *se)
@@ -2595,6 +2599,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;
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index 0dcf2ef57a..9f6582343c 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -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;
--
2.24.1
- [PATCH v2 096/109] virtiofsd: do not always set FUSE_FLOCK_LOCKS, (continued)
- [PATCH v2 096/109] virtiofsd: do not always set FUSE_FLOCK_LOCKS, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 098/109] virtiofsd: Reset O_DIRECT flag during file open, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 097/109] virtiofsd: convert more fprintf and perror to use fuse log infra, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 100/109] virtiofsd: add definition of fuse_buf_writev(), Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 099/109] virtiofsd: Fix data corruption with O_APPEND write in writeback mode, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 101/109] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 102/109] virtiofsd: process requests in a thread pool, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 103/109] virtiofsd: prevent FUSE_INIT/FUSE_DESTROY races, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 104/109] virtiofsd: fix lo_destroy() resource leaks, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 105/109] virtiofsd: add --thread-pool-size=NUM option,
Dr. David Alan Gilbert (git) <=
- [PATCH v2 106/109] virtiofsd: Convert lo_destroy to take the lo->mutex lock itself, Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 107/109] virtiofsd/passthrough_ll: Pass errno to fuse_reply_err(), Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 108/109] virtiofsd: stop all queue threads on exit in virtio_loop(), Dr. David Alan Gilbert (git), 2020/01/21
- [PATCH v2 109/109] virtiofsd: add some options to the help message, Dr. David Alan Gilbert (git), 2020/01/21
- Re: [PATCH v2 000/109] virtiofs daemon [all], no-reply, 2020/01/21
- Re: [PATCH v2 000/109] virtiofs daemon [all], Philippe Mathieu-Daudé, 2020/01/21