From f12d9686d4d673e59b8f561c49996820763220b1 Mon Sep 17 00:00:00 2001 From: Joseph Dodge Date: Thu, 24 Aug 2017 14:37:10 +0200 Subject: Add idle_threads mount option. --- include/fuse.h | 10 +++++++--- include/fuse_common.h | 24 +++++++++++++++++++++++- include/fuse_lowlevel.h | 11 ++++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/fuse.h b/include/fuse.h index 4898029..4816617 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -964,13 +964,17 @@ void fuse_exit(struct fuse *f); * in the callback function of fuse_operations is also thread-safe. * * @param f the FUSE handle - * @param clone_fd whether to use separate device fds for each thread - * (may increase performance) + * @param config loop configuration * @return see fuse_session_loop() * * See also: fuse_loop() */ -int fuse_loop_mt(struct fuse *f, int clone_fd); +#if FUSE_USE_VERSION < 32 +int fuse_loop_mt_31(struct fuse *f, int clone_fd); +#define fuse_loop_mt(f, clone_fd) fuse_loop_mt_31(f, clone_fd) +#else +int fuse_loop_mt(struct fuse *f, struct fuse_loop_config *config); +#endif /** * Get the current context diff --git a/include/fuse_common.h b/include/fuse_common.h index ecaa906..ff78cc9 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -22,7 +22,7 @@ #define FUSE_MAJOR_VERSION 3 /** Minor version of FUSE library interface */ -#define FUSE_MINOR_VERSION 1 +#define FUSE_MINOR_VERSION 2 #define FUSE_MAKE_VERSION(maj, min) ((maj) * 10 + (min)) #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION) @@ -79,7 +79,29 @@ struct fuse_file_info { uint32_t poll_events; }; +/** + * Configuration parameters passed to fuse_session_loop_mt() and + * fuse_loop_mt(). + */ +struct fuse_loop_config { + /** + * whether to use separate device fds for each thread + * (may increase performance) + */ + int clone_fd; + /** + * The maximum number of available worker threads before they + * start to get deleted when they become idle. If not + * specified, the default is 10. + * + * Adjusting this has performance implications; a very small number + * of threads in the pool will cause a lot of thread creation and + * deletion overhead and performance may suffer. When set to 0, a new + * thread will be created to service every operation. + */ + unsigned int max_idle_threads; +}; /************************************************************************** * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' * diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index ebfc626..72942ab 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -1760,6 +1760,7 @@ struct fuse_cmdline_opts { int show_version; int show_help; int clone_fd; + unsigned int max_idle_threads; }; /** @@ -1857,11 +1858,15 @@ int fuse_session_loop(struct fuse_session *se); * fuse_session_loop(). * * @param se the session - * @param clone_fd whether to use separate device fds for each thread - * (may increase performance) + * @param config session loop configuration * @return see fuse_session_loop() */ -int fuse_session_loop_mt(struct fuse_session *se, int clone_fd); +#if FUSE_USE_VERSION < 32 +int fuse_session_loop_mt_31(struct fuse_session *se, int clone_fd); +#define fuse_session_loop_mt(se, clone_fd) fuse_session_loop_mt_31(se, clone_fd) +#else +int fuse_session_loop_mt(struct fuse_session *se, struct fuse_loop_config *config); +#endif /** * Flag a session as terminated. -- cgit v1.2.3