From dc1b698847456174c20ffe393f9c46eab6b86be8 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 2 Aug 2020 16:01:23 -0400 Subject: [PATCH] libfuse cleanup: remove single threaded --- libfuse/Makefile | 1 - libfuse/include/fuse.h | 13 +----- libfuse/include/fuse_common.h | 7 ++-- libfuse/include/fuse_lowlevel.h | 8 ---- libfuse/lib/fuse.c | 73 --------------------------------- libfuse/lib/fuse_i.h | 1 - libfuse/lib/fuse_loop.c | 46 --------------------- libfuse/lib/fuse_mt.c | 4 +- libfuse/lib/helper.c | 34 ++++++--------- 9 files changed, 17 insertions(+), 170 deletions(-) delete mode 100644 libfuse/lib/fuse_loop.c diff --git a/libfuse/Makefile b/libfuse/Makefile index 7fec8a9b..c8845fba 100644 --- a/libfuse/Makefile +++ b/libfuse/Makefile @@ -34,7 +34,6 @@ SRC = \ lib/fuse_dirents.c \ lib/fuse.c \ lib/fuse_kern_chan.c \ - lib/fuse_loop.c \ lib/fuse_loop_mt.c \ lib/fuse_lowlevel.c \ lib/fuse_mt.c \ diff --git a/libfuse/include/fuse.h b/libfuse/include/fuse.h index 8e2c9474..1feff3f2 100644 --- a/libfuse/include/fuse.h +++ b/libfuse/include/fuse.h @@ -664,17 +664,6 @@ extern "C" { */ void fuse_destroy(struct fuse *f); - /** - * FUSE event loop. - * - * Requests from the kernel are processed, and the appropriate - * operations are called. - * - * @param f the FUSE handle - * @return 0 if no error occurred, -1 otherwise - */ - int fuse_loop(struct fuse *f); - /** * Exit from event loop * @@ -903,7 +892,7 @@ extern "C" { /** This is the part of fuse_main() before the event loop */ struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, - char **mountpoint, int *multithreaded, + char **mountpoint, void *user_data); /** This is the part of fuse_main() after the event loop */ diff --git a/libfuse/include/fuse_common.h b/libfuse/include/fuse_common.h index c7d47ea8..0de750ef 100644 --- a/libfuse/include/fuse_common.h +++ b/libfuse/include/fuse_common.h @@ -235,7 +235,6 @@ extern "C" { * * '-f' foreground * '-d' '-odebug' foreground, but keep the debug option - * '-s' single threaded * '-h' '--help' help * '-ho' help without header * '-ofsname=..' file system name, if not present, then set to the program @@ -245,12 +244,12 @@ extern "C" { * * @param args argument vector * @param mountpoint the returned mountpoint, should be freed after use - * @param multithreaded set to 1 unless the '-s' option is present * @param foreground set to 1 if one of the relevant options is present * @return 0 on success, -1 on failure */ - int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint, - int *multithreaded, int *foreground); + int fuse_parse_cmdline(struct fuse_args *args, + char **mountpoint, + int *foreground); /** * Go into the background diff --git a/libfuse/include/fuse_lowlevel.h b/libfuse/include/fuse_lowlevel.h index d3e43e64..ffb7e1f0 100644 --- a/libfuse/include/fuse_lowlevel.h +++ b/libfuse/include/fuse_lowlevel.h @@ -1698,14 +1698,6 @@ extern "C" { */ void *fuse_session_data(struct fuse_session *se); - /** - * Enter a single threaded event loop - * - * @param se the session - * @return 0 on success, -1 on error - */ - int fuse_session_loop(struct fuse_session *se); - /** * Enter a multi-threaded event loop * diff --git a/libfuse/lib/fuse.c b/libfuse/lib/fuse.c index fd7bdd0d..8a53495b 100644 --- a/libfuse/lib/fuse.c +++ b/libfuse/lib/fuse.c @@ -4177,79 +4177,6 @@ struct fuse_cmd *fuse_read_cmd(struct fuse *f) return cmd; } -static int fuse_session_loop_remember(struct fuse *f) -{ - struct fuse_session *se = f->se; - int res = 0; - struct timespec now; - time_t next_clean; - struct fuse_chan *ch = fuse_session_next_chan(se, NULL); - size_t bufsize = fuse_chan_bufsize(ch); - char *buf = (char *) malloc(bufsize); - struct pollfd fds = { - .fd = fuse_chan_fd(ch), - .events = POLLIN - }; - - if (!buf) { - fprintf(stderr, "fuse: failed to allocate read buffer\n"); - return -1; - } - - curr_time(&now); - next_clean = now.tv_sec; - while (!fuse_session_exited(se)) { - struct fuse_chan *tmpch = ch; - struct fuse_buf fbuf = { - .mem = buf, - .size = bufsize, - }; - unsigned timeout; - - curr_time(&now); - if (now.tv_sec < next_clean) - timeout = next_clean - now.tv_sec; - else - timeout = 0; - - res = poll(&fds, 1, timeout * 1000); - if (res == -1) { - if (errno == -EINTR) - continue; - else - break; - } else if (res > 0) { - res = fuse_session_receive_buf(se, &fbuf, &tmpch); - - if (res == -EINTR) - continue; - if (res <= 0) - break; - - fuse_session_process_buf(se, &fbuf, tmpch); - } else { - timeout = fuse_clean_cache(f); - curr_time(&now); - next_clean = now.tv_sec + timeout; - } - } - - free(buf); - fuse_session_reset(se); - return res < 0 ? -1 : 0; -} - -int fuse_loop(struct fuse *f) -{ - if (!f) - return -1; - - if (lru_enabled(f)) - return fuse_session_loop_remember(f); - - return fuse_session_loop(f->se); -} - int fuse_invalidate(struct fuse *f, const char *path) { (void) f; diff --git a/libfuse/lib/fuse_i.h b/libfuse/lib/fuse_i.h index 80b5a683..d951f4ad 100644 --- a/libfuse/lib/fuse_i.h +++ b/libfuse/lib/fuse_i.h @@ -120,7 +120,6 @@ struct fuse *fuse_setup_common(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, - int *multithreaded, int *fd, void *user_data); diff --git a/libfuse/lib/fuse_loop.c b/libfuse/lib/fuse_loop.c deleted file mode 100644 index e180577b..00000000 --- a/libfuse/lib/fuse_loop.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - FUSE: Filesystem in Userspace - Copyright (C) 2001-2007 Miklos Szeredi - - This program can be distributed under the terms of the GNU LGPLv2. - See the file COPYING.LIB -*/ - -#include "fuse_lowlevel.h" - -#include -#include -#include - -int fuse_session_loop(struct fuse_session *se) -{ - int res = 0; - struct fuse_chan *ch = fuse_session_next_chan(se, NULL); - size_t bufsize = fuse_chan_bufsize(ch); - char *buf = (char*)calloc(bufsize,1); - if (!buf) { - fprintf(stderr, "fuse: failed to allocate read buffer\n"); - return -1; - } - - while (!fuse_session_exited(se)) { - struct fuse_chan *tmpch = ch; - struct fuse_buf fbuf = { - .mem = buf, - .size = bufsize, - }; - - res = fuse_session_receive_buf(se, &fbuf, &tmpch); - - if (res == -EINTR) - continue; - if (res <= 0) - break; - - fuse_session_process_buf(se, &fbuf, tmpch); - } - - free(buf); - fuse_session_reset(se); - return res < 0 ? -1 : 0; -} diff --git a/libfuse/lib/fuse_mt.c b/libfuse/lib/fuse_mt.c index b720f0fe..6a2f9581 100644 --- a/libfuse/lib/fuse_mt.c +++ b/libfuse/lib/fuse_mt.c @@ -62,7 +62,7 @@ static int mt_chan_receive(struct fuse_chan **chp, char *buf, size_t size) if (cmd == NULL) return 0; - *(struct fuse_cmd **) buf = cmd; + *(struct fuse_cmd **)buf = cmd; return sizeof(cmd); } @@ -121,5 +121,3 @@ int fuse_loop_mt(struct fuse *f) fuse_stop_cleanup_thread(f); return res; } - -FUSE_SYMVER(".symver fuse_loop_mt_proc,__fuse_loop_mt@"); diff --git a/libfuse/lib/helper.c b/libfuse/lib/helper.c index c1e6d7f1..c9f0cc5f 100644 --- a/libfuse/lib/helper.c +++ b/libfuse/lib/helper.c @@ -29,7 +29,6 @@ enum { struct helper_opts { - int singlethread; int foreground; int nodefault_subtype; char *mountpoint; @@ -41,20 +40,19 @@ static const struct fuse_opt fuse_helper_opts[] = { - FUSE_HELPER_OPT("-d", foreground), + FUSE_HELPER_OPT("-d", foreground), FUSE_HELPER_OPT("debug", foreground), - FUSE_HELPER_OPT("-f", foreground), - FUSE_HELPER_OPT("-s", singlethread), + FUSE_HELPER_OPT("-f", foreground), FUSE_HELPER_OPT("fsname=", nodefault_subtype), FUSE_HELPER_OPT("subtype=", nodefault_subtype), FUSE_OPT_KEY("-h", KEY_HELP), - FUSE_OPT_KEY("--help", KEY_HELP), + FUSE_OPT_KEY("--help", KEY_HELP), FUSE_OPT_KEY("-ho", KEY_HELP_NOHEADER), FUSE_OPT_KEY("-V", KEY_VERSION), FUSE_OPT_KEY("--version", KEY_VERSION), FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), - FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), - FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP), + FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), + FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP), FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_KEEP), FUSE_OPT_END }; @@ -77,7 +75,6 @@ static void helper_help(void) "FUSE options:\n" " -d -o debug enable debug output (implies -f)\n" " -f foreground operation\n" - " -s disable multi-threaded operation\n" "\n" ); } @@ -149,7 +146,6 @@ static int add_default_subtype(const char *progname, struct fuse_args *args) int fuse_parse_cmdline(struct fuse_args *args_, char **mountpoint_, - int *multithreaded_, int *foreground_) { int res; @@ -176,8 +172,6 @@ fuse_parse_cmdline(struct fuse_args *args_, else free(hopts.mountpoint); - if(multithreaded_) - *multithreaded_ = !hopts.singlethread; if(foreground_) *foreground_ = hopts.foreground; @@ -296,7 +290,6 @@ struct fuse *fuse_setup_common(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, - int *multithreaded, int *fd, void *user_data) { @@ -306,7 +299,7 @@ struct fuse *fuse_setup_common(int argc, char *argv[], int foreground; int res; - res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground); + res = fuse_parse_cmdline(&args, mountpoint, &foreground); if (res == -1) return NULL; @@ -345,10 +338,10 @@ struct fuse *fuse_setup_common(int argc, char *argv[], struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, - char **mountpoint, int *multithreaded, void *user_data) + char **mountpoint, void *user_data) { return fuse_setup_common(argc, argv, op, op_size, mountpoint, - multithreaded, NULL, user_data); + NULL, user_data); } static void fuse_teardown_common(struct fuse *fuse, char *mountpoint) @@ -372,18 +365,15 @@ static int fuse_main_common(int argc, char *argv[], { struct fuse *fuse; char *mountpoint; - int multithreaded; int res; - fuse = fuse_setup_common(argc, argv, op, op_size, &mountpoint, - &multithreaded, NULL, user_data); + fuse = fuse_setup_common(argc, argv, op, op_size, + &mountpoint, + NULL, user_data); if (fuse == NULL) return 1; - if (multithreaded) - res = fuse_loop_mt(fuse); - else - res = fuse_loop(fuse); + res = fuse_loop_mt(fuse); fuse_teardown_common(fuse, mountpoint); if (res == -1)