aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse_loop_mt.c
AgeCommit message (Collapse)AuthorLines
2025-02-10lib: Set thread namesBernd Schubert-0/+4
Main worker threads: fuse_worker high level clean up threads: "fuse_prune_nodes" Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2024-12-18Rename _int to _internalBernd Schubert-2/+3
_int can be confused with 'integer'
2024-12-18Allow to have page aligned writesBernd Schubert-2/+2
Read/writes IOs should be page aligned as fuse server might need to copy data to another buffer otherwise in order to fulfill network or device storage requirements. Simple reproducer is example/passthrough* and opening a file with O_DIRECT - without this change writing to that file failed with -EINVAL if the underlying file system was using ext4 (for passthrough_hp the 'passthrough' feature has to be disabled). The mis-alignment from fuse kernel is not ideal, but we can handle it by allocation one page more than needed and then using a buffer that is set up to compensate for kernel misalignment. This also only set se->buf_reallocable to true when called by a libfuse internal caller - we do not know what external callers are doing with the buffer - update to commit 0e0f43b79b9b
2024-10-11Add libfuse util strtol wrapperJoanne Koong-2/+12
Add a wrapper around strtol for more rigorous error checking and convert uses of atoi and strtol to use this instead.
2024-05-05Fix missing fuse_loop_cfg_destroy() in fuse_session_loop_mt_31 (#944)Bernd Schubert-1/+6
All credits to Miklos Szeredi <miklos@szeredi.hu> for spotting this. Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
2024-04-18Add clone_fd to custom IO (#927)legezywzh-5/+24
Define a new clone_fd() helper for fuse_custom_io, users can implement their own clone fd logic. Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2023-10-25fuse_clone_chan: avoid additional FD_CLOEXEC setting if O_CLOEXEC defined (#852)legezywzh-0/+2
Since open(2) has been called with O_CLOEXEC flag if defined. Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com> Co-authored-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2023-02-20Avoid max-idle threads warningBernd Schubert-3/+5
If a program with API before 312 did not set max_idle_threads the new default from fuse_parse_cmdline_312() is applied, which sets UINT_MAX (-1). Later in compat fuse_session_loop_mt_32 the old config v1 struct is converted and that conversion prints a warning if the default unset value was used. This could have also happened to programs using the current API, which just apply values struct fuse_cmdline_opts, without checking if the defaults are set.
2023-01-28Install a the configure_file (config.h) and use in headersBernd Schubert-1/+1
This addresses: https://github.com/libfuse/libfuse/issues/724 HAVE_LIBC_VERSIONED_SYMBOLS configures the library if to use versioned symbols and is set at meson configuration time. External filesystems (the main target, actually) include fuse headers and the preprocessor then acts on HAVE_LIBC_VERSIONED_SYMBOLS. Problem was now that 'config.h' was not distributed with libfuse and so HAVE_LIBC_VERSIONED_SYMBOLS was never defined with external tools and the preprocessor did the wrong decision. This commit also increases the the minimal meson version, as this depends on meson feature only available in 0.50 <quote 'meson' > WARNING: Project specifies a minimum meson_ version '>= 0.42' but uses features which were added in newer versions: * 0.50.0: {'install arg in configure_file'} </quote> Additionally the config file has been renamed to "fuse_config.h" to avoid clashes - 'config.h' is not very specific.
2023-01-13passthrough_hp: Add options for clone_fd, max_threads, daemonizeBernd Schubert-0/+9
This is useful for benchmarking. Note: This changes behavior - passthrough_hp runs in background by default now.
2022-12-01Make it work even if max_idle_threads is set to 0Zhansong Gao-1/+1
It may happen that none of the worker threads are running if max_idle_threads is set to 0 although few people will do this. Adding a limit of keeping at least one worker thread will make our code more rigorous. Signed-off-by: Zhansong Gao <zhsgao@hotmail.com>
2022-09-04fuse_session_loop_mt: Accept a NULL config - use defaultsBernd Schubert-7/+24
If an application does not want to bother with the session and wants to keep defaults, it can now just pass a NULL as config parameter.
2022-09-04fuse-loop/fuse_do_work: Avoid lots of thread creations/destructionsBernd Schubert-3/+23
On benchmarking metadata operations with a single threaded bonnie++ and "max_idle_threads" limited to 1, 'top' was showing suspicious 160% cpu usage. Profiling the system with flame graphs showed that an astonishing amount of CPU time was spent in thread creation and destruction. After verifying the code it turned out that fuse_do_work() was creating a new thread every time all existing idle threads were already busy. And then just a few lines later after processing the current request it noticed that it had created too many threads and destructed the current thread. I.e. there was a thread creation/destruction ping-pong. Code is changed to only create new threads if the max number of threads is not reached. Furthermore, thread destruction is disabled, as creation/destruction is expensive in general. With this change cpu usage of passthrough_hp went from ~160% to ~80% (with different values of max_idle_threads). And bonnie values got approximately faster by 90%. This is a with single threaded bonnie++ bonnie++ -x 4 -q -s0 -d <path> -n 30:1:1:10 -r 0 Without this patch, using the default max_idle_threads=10 and just a single bonnie++ the thread creation/destruction code path is not triggered. Just one libfuse and one application thread is just a corner case - the requirement for the issue was just n-application-threads >= max_idle_threads. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2022-09-04API update for fuse_loop_config additionsBernd Schubert-7/+86
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>
2021-04-12Remove unused fuse_worker bufsize (#590)Hookey-1/+0
Not used since https://github.com/libfuse/libfuse/commit/561d7054d856eea6c2d634093546d6af773dada9
2020-10-29remove fuse_mutex_initRosen Penev-2/+2
This seems to have been added before 2006 to fix a uclibc bug. It doesn't seem to be the case anymore so just get rid of it. Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-09-11Implement GCC 10 style symbol versioning (#545)Tom Callaway-2/+2
2019-09-04Introduce callback for loggingStefan Hajnoczi-7/+7
Introduce an API for custom log handler functions. This allows libfuse applications to send messages to syslog(3) or other logging systems. See include/fuse_log.h for details. Convert libfuse from fprintf(stderr, ...) to log_fuse(level, ...). Most messages are error messages with FUSE_LOG_ERR log level. There are also some debug messages which now use the FUSE_LOG_DEBUG log level. Note that lib/mount_util.c is used by both libfuse and fusermount3. Since fusermount3 does not link against libfuse, we cannot call fuse_log() from lib/mount_util.c. This file will continue to use fprintf(stderr, ...) until someone figures out how to split it up. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-11-06Revert "Do not include struct fuse_buf in struct fuse_worker"Nikolaus Rath-9/+13
This reverts commit 161983e2416bc6e26bbbe89664fff62c48c70858, because this causes resource leaks when threads are terminated by pthread_cancel(). Fixes: #313.
2018-09-17Do not include struct fuse_buf in struct fuse_workerNikolaus Rath-10/+9
This is only used in fuse_do_work(), so we can put it on the stack.
2017-09-19Make *_loop_mt() available in version 3.0 againNikolaus Rath-1/+1
The old versions of these symbols were defined with version tag FUSE_3.0, so this is what we have to use in the .symver directive.
2017-09-19Don't use external symbol names in internal filesNikolaus Rath-1/+0
The fuse_session_loop_mt() and fuse_loop_mt() symbols are only visible when linking against the shared object. The code in lib/, however, is compiled *into* the shared object and should thus use the internal names of these functions. Surprisingly enough, the code still worked before - but only when link time optimization was disabled. Unfortunately, we still can't compile with LTO because it seems that enabling LTO somehow makes the tagged symbols vanish. Without lto, we have: $ nm lib/libfuse3.so | grep fuse_new 0000000000011070 T fuse_new_30 0000000000010a00 t fuse_new_31 0000000000011070 T fuse_new@FUSE_3.0 0000000000010a00 T fuse_new@@FUSE_3.1 and with LTO: $ nm lib/libfuse3.so | grep fuse_new 0000000000019a70 T fuse_new_30 0000000000019270 t fuse_new_31 See also issue #198.
2017-08-24Add idle_threads mount option.Joseph Dodge-3/+17
2017-08-23fuse_loop_mt(): on error, return errno rather than -1.Nikolaus Rath-1/+1
2016-11-16Add support for more detailed error codes from main loopNikolaus Rath-0/+2
2016-10-13Make -o clone_fd into a parameter of session_loop_mt().Nikolaus Rath-3/+5
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.
2016-10-04Merge fuse_ll into fuse_session (part 3)Nikolaus Rath-2/+2
Replace se->f with se.
2016-10-03Merge master fuse_chan into fuse_session.Nikolaus Rath-11/+51
This is a code simplification patch. - It confines most of the implementation channel implementation into fuse_loop_mt (which is its only user). - It makes it more obvious in the code that channels are only ever used when using -o clone_fd and multi-threaded main loop. - It simplies the definition of both struct fuse_session and struct fuse_chan. - Theoretically it should result in (minuscule) performance improvements when not using -o clone_fd. - Overall, it removes a lot more lines of source code than it adds :-).
2016-10-02Extended per-file comments.Nikolaus Rath-0/+2
This should make more clear what file contains code for what purpose.
2016-10-02Turned fuse_session_{process,receive}_buf into wrapper functions.Nikolaus Rath-2/+2
2016-03-29Inlined fuse_chan_fdNikolaus Rath-1/+1
2015-05-18libfuse: add "clone_fd" optionMiklos Szeredi-2/+53
This creates a separate device file descriptor for each processing thread, which might improve performance.
2013-07-24libfuse: remove "-D_FILE_OFFSET_BITS=64" from fuse.pcMiklos Szeredi-0/+1
add AC_SYS_LARGEFILE to your configure.ac instead.
2013-07-17Merge https://github.com/qknight/fuse-fuseMiklos Szeredi-0/+0
2013-06-21libfuse: remove fuse_chan_bufsize()Miklos Szeredi-19/+8
Remove fuse_chan_bufsize() from the lowlevel API. fuse_session_receive_buf() is now responsible for allocating memory for the buffer.
2013-06-21libfuse: remove fuse_chan_(send|receive)Miklos Szeredi-3/+2
Move the fuse_chan_ops.send and .receive implementations to fuse_lowlevel.c. The abstraction wasn't actually useful and made the the splice implementation more difficult. Remove fuse_chan_ops.send and fuse_chan_ops.receive.
2013-06-21libfuse: replace fuse_session_next_chanMiklos Szeredi-1/+1
Replace fuse_session_next_chan() with fuse_session_chan(), as multiple channels per session were never actually supported and probably never will.
2013-06-20- added a doxygen main pageJoachim Schiele-0/+0
- modified all examples to be included in doxygen - modified the API documentation to have more details - added the 490px_FUSE_structure.svg.png (c) wikipedia
2013-03-19libfuse: fix thread cancel raceMiklos Szeredi-0/+2
Exiting a worker my race with cancelling that same worker. This caused a segmenation fault. Reported and tested by Anatol Pomozov
2012-01-02Remove unnecessary mutex unlock at the end of multithreaded event loopMiklos Szeredi-1/+0
2011-06-02add "remember" optiontherealneworld@gmail.com-19/+32
This works similar to "noforget" except that eventually the node will be allowed to expire from the cache.
2011-05-19Allow batching of forget requestsMiklos Szeredi-3/+7
This allows forget requests to be processed faster and doesn't require a modification to fuse filesystems. Reported by Terje Malmedal
2011-02-02libfuse: fuse_session_loop_mt() shouldn't pause when exiting worker threadsMiklos Szeredi-2/+0
In fuse_session_loop_mt() don't pause when exiting the worker threads. The pause() was added in 2.2.1 to prevent segfault on pthread_cancel() on an exited, detached thread. Now worker threads are not detached and pthread_cancel() should work fine even after the thread exited. Reported by Boris Protopopov
2010-11-08libfuse: support zero copy writes in lowlevel interfaceMiklos Szeredi-3/+8
Add new ->write_buf() method to low level interface. This allows passig a generic buffer, either containing a memory buffer or a file descriptor. This allows implementing zero copy writes. Add fuse_session_receive_buf() and fuse_session_process_buf() which may be used in event loop implementations to replace fuse_chan_recv() and fuse_session_process() respectively.
2008-03-07Add queuing on contention to per-node lock algorithm...Miklos Szeredi-1/+6
2008-02-08If the "FUSE_THREAD_STACK" environment is set, initialize the stack size of ↵Miklos Szeredi-1/+13
threads by this value
2007-12-12change indentingMiklos Szeredi-173/+174
2007-10-16Clarify licence version to be "LGPLv2" for the libraryMiklos Szeredi-1/+1
2007-05-29lib: don't create new thread for each FORGET request...Miklos Szeredi-2/+14
2007-05-24lib: fix memory leak on thread creation failure...Miklos Szeredi-0/+2