aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse_i.h
diff options
context:
space:
mode:
authorBernd Schubert <bschubert@ddn.com>2022-04-08 22:30:27 +0200
committerNikolaus Rath <Nikolaus@rath.org>2022-09-04 13:07:15 +0100
commit30a126c5f9009e8ff8e369c563eb941679bec252 (patch)
treeaa27206391ed90acf95a9339b13f1c4202c63105 /lib/fuse_i.h
parent7657ec158becdc59656c59dff40346fefde78cb2 (diff)
downloadlibfuse-30a126c5f9009e8ff8e369c563eb941679bec252.tar.gz
API update for fuse_loop_config additions
struct fuse_loop_config was passed as a plain struct, without any version identifer. This had two implications 1) Any addition of new parameters required a FUSE_SYMVER for fuse_session_loop_mt() and fuse_loop_mt() as otherwise a read beyond end-of previous struct size might have happened. 2) Filesystems also might have been recompiled and the developer might not have noticed the struct extensions and unexpected for the developer (or people recomliling the code) uninitialized parameters would have been passed. Code is updated to have struct fuse_loop_config as an opaque/private data type for file systems that want version 312 (FUSE_MAKE_VERSION(3, 12)). The deprecated fuse_loop_config_v1 is visible, but should not be used outside of internal conversion functions File systems that want version >= 32 < 312 get the previous struct (through ifdefs) and the #define of fuse_loop_mt and fuse_session_loop_mt ensures that these recompiled file systems call into the previous API, which then converts the struct. This is similar to existing compiled applications when just libfuse updated, but binaries it is solved with the FUSE_SYMVER ABI compact declarations. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Diffstat (limited to 'lib/fuse_i.h')
-rw-r--r--lib/fuse_i.h56
1 files changed, 54 insertions, 2 deletions
diff --git a/lib/fuse_i.h b/lib/fuse_i.h
index d38b630..6930a20 100644
--- a/lib/fuse_i.h
+++ b/lib/fuse_i.h
@@ -87,6 +87,50 @@ struct fuse_module {
int ctr;
};
+/**
+ * Configuration parameters passed to fuse_session_loop_mt() and
+ * fuse_loop_mt().
+ *
+ * Internal API to avoid exposing the plain data structure and
+ * causing compat issues after adding or removing struct members.
+ *
+ */
+#if FUSE_USE_VERSION >= FUSE_MAKE_VERSION(3, 12)
+struct fuse_loop_config
+{
+ /* verififier that a correct struct was was passed. This is especially
+ * needed, as versions below (3, 12) were using a public struct
+ * (now called fuse_loop_config_v1), which was hard to extend with
+ * additional parameters, without risking that file system implementations
+ * would not have noticed and might either pass uninitialized members
+ * or even too small structs.
+ * fuse_loop_config_v1 has clone_fd at this offset, which should be either 0
+ * or 1. v2 or even higher version just need to set a value here
+ * which not conflicting and very unlikely as having been set by
+ * file system implementation.
+ */
+ int version_id;
+
+ /**
+ * 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.
+ * The special value of -1 means that this parameter is disabled.
+ */
+ int max_idle_threads;
+};
+#endif
+
/* ----------------------------------------------------------- *
* Channel interface (when using -o clone_fd) *
* ----------------------------------------------------------- */
@@ -128,8 +172,16 @@ void fuse_session_process_buf_int(struct fuse_session *se,
struct fuse *fuse_new_31(struct fuse_args *args, const struct fuse_operations *op,
size_t op_size, void *private_data);
-int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config);
-int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config);
+int fuse_loop_mt_312(struct fuse *f, struct fuse_loop_config *config);
+int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *config);
+
+/**
+ * Internal verifier for the given config.
+ *
+ * @return negative standard error code or 0 on success
+ */
+int fuse_loop_cfg_verify(struct fuse_loop_config *config);
+
#define FUSE_MAX_MAX_PAGES 256
#define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32