[PATCH v1] erofs-utils: fuse: support FUSE 2/3 multi-threading

Gao Xiang hsiangkao at linux.alibaba.com
Tue Dec 12 22:08:04 AEDT 2023



On 2023/12/12 15:38, Li Yiyan wrote:
> From: Li Yiyan <lyy0627 at sjtu.edu.cn>
> 
> Introduce multi-threading support for FUSE and adjust the configure.ac
> to allow users of FUSE 3(> 3.2) to use API version 32, while maintaining
> compatibility with API version 30 for FUSE 3 (3.0/3.1) and API version
> 26 for FUSE 2.
> 
> Signed-off-by: Li Yiyan <lyy0627 at sjtu.edu.cn>> ---
>   configure.ac |  8 +++++++-
>   fuse/main.c  | 19 +++++++++++++++++--
>   2 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 9294e0c..bf6e99f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -343,7 +343,13 @@ AS_IF([test "x$enable_fuse" != "xno"], [
>     saved_LIBS="$LIBS"
>     saved_CPPFLAGS=${CPPFLAGS}
>     PKG_CHECK_MODULES([libfuse3], [fuse3 >= 3.0], [
> -    AC_DEFINE([FUSE_USE_VERSION], [30], [used FUSE API version])
> +    PKG_CHECK_MODULES([libfuse3_0], [fuse3 >= 3.0 fuse3 < 3.2], [
> +      AC_DEFINE([FUSE_USE_VERSION], [30], [used FUSE API version])
> +    ], [
> +      PKG_CHECK_MODULES([libfuse3_2], [fuse3 >= 3.2], [
> +        AC_DEFINE([FUSE_USE_VERSION], [32], [used FUSE API version])
> +      ])
> +    ])
>       CPPFLAGS="${libfuse3_CFLAGS} ${CPPFLAGS}"
>       LIBS="${libfuse3_LIBS} $LIBS"
>       AC_CHECK_LIB(fuse3, fuse_session_new, [], [
> diff --git a/fuse/main.c b/fuse/main.c
> index f07165c..77b2d50 100644
> --- a/fuse/main.c
> +++ b/fuse/main.c
> @@ -699,7 +699,19 @@ int main(int argc, char *argv[])
>   		EROFSFUSE_MOUNT_MSG
>   		if (fuse_daemonize(opts.foreground) >= 0) {
>   			if (fuse_set_signal_handlers(se) >= 0) {
> -				ret = fuse_session_loop(se);
> +				if (opts.singlethread) {
> +					ret = fuse_session_loop(se);
> +				} else {
> +#if FUSE_MINOR_VERSION < 2

Can we check FUSE_USE_VERSION directly?
if FUSE_USE_VERSION is neither 30 or 32, let's raise a build error with

#error unsupported FUSE_USE_VERSION

instead.

Thanks,
Gao Xiang

> +					ret = fuse_session_loop_mt(se, opts.clone_fd);
> +#else
> +					struct fuse_loop_config config = {
> +						.clone_fd = opts.clone_fd,
> +						.max_idle_threads = opts.max_idle_threads
> +					};
> +					ret = fuse_session_loop_mt(se, &config);
> +#endif
> +				}
>   				fuse_remove_signal_handlers(se);
>   			}
>   			fuse_session_unmount(se);
> @@ -717,7 +729,10 @@ int main(int argc, char *argv[])
>   		if (fuse_daemonize(opts.foreground) != -1) {
>   			if (fuse_set_signal_handlers(se) != -1) {
>   				fuse_session_add_chan(se, ch);
> -				ret = fuse_session_loop(se);
> +				if (opts.mt)
> +					ret = fuse_session_loop_mt(se);
> +				else
> +					ret = fuse_session_loop(se);
>   				fuse_remove_signal_handlers(se);
>   				fuse_session_remove_chan(ch);
>   			}


More information about the Linux-erofs mailing list