Browse Source

libfuse cleanup: remove single threaded

pull/809/head
Antonio SJ Musumeci 4 years ago
parent
commit
dc1b698847
  1. 1
      libfuse/Makefile
  2. 13
      libfuse/include/fuse.h
  3. 7
      libfuse/include/fuse_common.h
  4. 8
      libfuse/include/fuse_lowlevel.h
  5. 73
      libfuse/lib/fuse.c
  6. 1
      libfuse/lib/fuse_i.h
  7. 46
      libfuse/lib/fuse_loop.c
  8. 2
      libfuse/lib/fuse_mt.c
  9. 22
      libfuse/lib/helper.c

1
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 \

13
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 */

7
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

8
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
*

73
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;

1
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);

46
libfuse/lib/fuse_loop.c

@ -1,46 +0,0 @@
/*
FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU LGPLv2.
See the file COPYING.LIB
*/
#include "fuse_lowlevel.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
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;
}

2
libfuse/lib/fuse_mt.c

@ -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@");

22
libfuse/lib/helper.c

@ -29,7 +29,6 @@ enum {
struct helper_opts
{
int singlethread;
int foreground;
int nodefault_subtype;
char *mountpoint;
@ -44,7 +43,6 @@ struct fuse_opt fuse_helper_opts[] =
FUSE_HELPER_OPT("-d", foreground),
FUSE_HELPER_OPT("debug", foreground),
FUSE_HELPER_OPT("-f", foreground),
FUSE_HELPER_OPT("-s", singlethread),
FUSE_HELPER_OPT("fsname=", nodefault_subtype),
FUSE_HELPER_OPT("subtype=", nodefault_subtype),
FUSE_OPT_KEY("-h", KEY_HELP),
@ -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);
fuse_teardown_common(fuse, mountpoint);
if (res == -1)

Loading…
Cancel
Save