[PATCH v2] erofs-utils: fuse: support FUSE 2/3 multi-thread
Li Yiyan
lyy0627 at sjtu.edu.cn
Tue Dec 12 22:54:27 AEDT 2023
Support multi-threading for erofsfuse 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 | 21 +++++++++++++++++++--
2 files changed, 26 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..32f59a3 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -699,7 +699,21 @@ 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_USE_VERSION == 30
+ ret = fuse_session_loop_mt(se, opts.clone_fd);
+#elif FUSE_USE_VERSION == 32
+ struct fuse_loop_config config = {
+ .clone_fd = opts.clone_fd,
+ .max_idle_threads = opts.max_idle_threads
+ };
+ ret = fuse_session_loop_mt(se, &config);
+#else
+#error "FUSE_USE_VERSION not supported"
+#endif
+ }
fuse_remove_signal_handlers(se);
}
fuse_session_unmount(se);
@@ -717,7 +731,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);
}
--
2.34.1
More information about the Linux-erofs
mailing list