All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] erofs-utils: fuse: support FUSE 2/3 multi-threading
@ 2023-12-12  7:38 Li Yiyan
  2023-12-12 11:08 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Li Yiyan @ 2023-12-12  7:38 UTC (permalink / raw)
  To: linux-erofs

From: Li Yiyan <lyy0627@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@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
+					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);
 			}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-12 11:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12  7:38 [PATCH v1] erofs-utils: fuse: support FUSE 2/3 multi-threading Li Yiyan
2023-12-12 11:08 ` Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.