From: Nikolaus Rath Date: Tue, 11 Oct 2016 04:29:36 +0000 (-0700) Subject: Make -o clone_fd into a parameter of session_loop_mt(). X-Git-Tag: fuse-3.0.0rc1~50 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2bfa342cdadbcb3d4421dd752bbe1e63e0f6430f;p=qemu-gpiodev%2Flibfuse.git Make -o clone_fd into a parameter of session_loop_mt(). This option really affects the behavior of the session loop, not the low-level interface. Therefore, it does not belong in the fuse_session object. --- diff --git a/ChangeLog.rst b/ChangeLog.rst index 5ddefdb..8a99d85 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,6 +1,10 @@ Unreleased Changes ================== +* The `fuse_session_new` function no longer accepts the ``-o + clone_fd`` option. Instead, this has become a parameter of the + `fuse_session_loop_mt` and ``fuse_loop_mt` functions. + * For low-level file systems that implement the `write_buf` handler, the `splice_read` option is now enabled by default. As usual, this can be changed in the file system's `init` handler. diff --git a/example/hello_ll.c b/example/hello_ll.c index b830cb2..e0ce610 100644 --- a/example/hello_ll.c +++ b/example/hello_ll.c @@ -224,7 +224,7 @@ int main(int argc, char *argv[]) if (opts.singlethread) ret = fuse_session_loop(se); else - ret = fuse_session_loop_mt(se); + ret = fuse_session_loop_mt(se, opts.clone_fd); fuse_session_unmount(se); err_out3: diff --git a/example/notify_inval_entry.c b/example/notify_inval_entry.c index 898eff1..1c2a6c9 100644 --- a/example/notify_inval_entry.c +++ b/example/notify_inval_entry.c @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) { if (opts.singlethread) ret = fuse_session_loop(se); else - ret = fuse_session_loop_mt(se); + ret = fuse_session_loop_mt(se, opts.clone_fd); fuse_session_unmount(se); err_out3: diff --git a/example/notify_inval_inode.c b/example/notify_inval_inode.c index 1b813a0..c9ab4d8 100644 --- a/example/notify_inval_inode.c +++ b/example/notify_inval_inode.c @@ -350,7 +350,7 @@ int main(int argc, char *argv[]) { if (opts.singlethread) ret = fuse_session_loop(se); else - ret = fuse_session_loop_mt(se); + ret = fuse_session_loop_mt(se, opts.clone_fd); fuse_session_unmount(se); err_out3: diff --git a/example/notify_store_retrieve.c b/example/notify_store_retrieve.c index 76f3291..5b5fa63 100644 --- a/example/notify_store_retrieve.c +++ b/example/notify_store_retrieve.c @@ -393,7 +393,7 @@ int main(int argc, char *argv[]) { if (opts.singlethread) ret = fuse_session_loop(se); else - ret = fuse_session_loop_mt(se); + ret = fuse_session_loop_mt(se, opts.clone_fd); assert(retrieve_status != 1); fuse_session_unmount(se); diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c index 66f92cf..df9d7d3 100644 --- a/example/passthrough_ll.c +++ b/example/passthrough_ll.c @@ -504,7 +504,7 @@ int main(int argc, char *argv[]) if (opts.singlethread) ret = fuse_session_loop(se); else - ret = fuse_session_loop_mt(se); + ret = fuse_session_loop_mt(se, opts.clone_fd); fuse_session_unmount(se); err_out3: diff --git a/include/fuse.h b/include/fuse.h index 8943835..5b9082b 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -748,11 +748,13 @@ 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) * @return 0 if no error occurred, -1 otherwise * * See also: fuse_loop() */ -int fuse_loop_mt(struct fuse *f); +int fuse_loop_mt(struct fuse *f, int clone_fd); /** * Get the current context diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index 0f8c030..0b7ee2b 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -1657,6 +1657,7 @@ struct fuse_cmdline_opts { char *mountpoint; int show_version; int show_help; + int clone_fd; }; /** @@ -1727,9 +1728,11 @@ int fuse_session_loop(struct fuse_session *se); * Enter a multi-threaded event loop * * @param se the session + * @param clone_fd whether to use separate device fds for each thread + * (may increase performance) * @return 0 on success, -1 on error */ -int fuse_session_loop_mt(struct fuse_session *se); +int fuse_session_loop_mt(struct fuse_session *se, int clone_fd); /** * Flag a session as terminated. diff --git a/lib/cuse_lowlevel.c b/lib/cuse_lowlevel.c index c9aa47d..49fc7d4 100644 --- a/lib/cuse_lowlevel.c +++ b/lib/cuse_lowlevel.c @@ -350,7 +350,7 @@ int cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci, return 1; if (multithreaded) - res = fuse_session_loop_mt(se); + res = fuse_session_loop_mt(se, 0); else res = fuse_session_loop(se); diff --git a/lib/fuse.c b/lib/fuse.c index 3304d68..fb15b04 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -4378,7 +4378,7 @@ int fuse_loop(struct fuse *f) return fuse_session_loop(f->se); } -int fuse_loop_mt(struct fuse *f) +int fuse_loop_mt(struct fuse *f, int clone_fd) { if (f == NULL) return -1; @@ -4387,7 +4387,7 @@ int fuse_loop_mt(struct fuse *f) if (res) return -1; - res = fuse_session_loop_mt(fuse_get_session(f)); + res = fuse_session_loop_mt(fuse_get_session(f), clone_fd); fuse_stop_cleanup_thread(f); return res; } diff --git a/lib/fuse_i.h b/lib/fuse_i.h index 9f11da7..5ed23c7 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -86,7 +86,6 @@ struct fuse_session { uint64_t notify_ctr; struct fuse_notify_req notify_list; size_t bufsize; - int clone_fd; }; struct fuse_chan { diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index e6e2263..54fb56d 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -47,6 +47,7 @@ struct fuse_mt { sem_t finish; int exit; int error; + int clone_fd; }; static struct fuse_chan *fuse_chan_new(int fd) @@ -265,13 +266,13 @@ static int fuse_loop_start_thread(struct fuse_mt *mt) w->mt = mt; w->ch = NULL; - if (mt->se->clone_fd) { + if (mt->clone_fd) { w->ch = fuse_clone_chan(mt); if(!w->ch) { /* Don't attempt this again */ fprintf(stderr, "fuse: trying to continue " "without -o clone_fd.\n"); - mt->se->clone_fd = 0; + mt->clone_fd = 0; } } @@ -299,7 +300,7 @@ static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w) free(w); } -int fuse_session_loop_mt(struct fuse_session *se) +int fuse_session_loop_mt(struct fuse_session *se, int clone_fd) { int err; struct fuse_mt mt; @@ -307,6 +308,7 @@ int fuse_session_loop_mt(struct fuse_session *se) memset(&mt, 0, sizeof(struct fuse_mt)); mt.se = se; + mt.clone_fd = clone_fd; mt.error = 0; mt.numworker = 0; mt.numavail = 0; diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 0085863..33e0ae5 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2596,7 +2596,6 @@ static const struct fuse_opt fuse_ll_opts[] = { LL_OPTION("writeback_cache", opts.writeback_cache, 1), LL_OPTION("no_writeback_cache", opts.no_writeback_cache, 1), LL_OPTION("time_gran=%u", conn.time_gran, 0), - LL_OPTION("clone_fd", clone_fd, 1), FUSE_OPT_END }; @@ -2627,8 +2626,7 @@ void fuse_lowlevel_help(void) " -o readdirplus=S control readdirplus use (yes|no|auto)\n" " -o [no_]async_dio asynchronous direct I/O\n" " -o [no_]writeback_cache asynchronous, buffered writes\n" -" -o time_gran=N time granularity in nsec\n" -" -o clone_fd clone fuse device file descriptors\n\n"); +" -o time_gran=N time granularity in nsec\n\n"); } void fuse_session_destroy(struct fuse_session *se) diff --git a/lib/helper.c b/lib/helper.c index cc5cefc..ea06d81 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -45,6 +45,7 @@ static const struct fuse_opt fuse_helper_opts[] = { FUSE_HELPER_OPT("subtype=", nodefault_subtype), FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP), FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_KEEP), + FUSE_HELPER_OPT("clone_fd", clone_fd), FUSE_OPT_END }; @@ -56,6 +57,7 @@ void fuse_cmdline_help(void) " -d -o debug enable debug output (implies -f)\n" " -f foreground operation\n" " -s disable multi-threaded operation\n" + " -o clone_fd use separate fuse device fd for each thread\n" "\n"); } @@ -246,7 +248,7 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, if (opts.singlethread) res = fuse_loop(fuse); else - res = fuse_loop_mt(fuse); + res = fuse_loop_mt(fuse, opts.clone_fd); if (res) res = 1;