- std::stoi threw std::out_of_range for a func.readdir concurrency or
queue depth above INT_MAX, e.g. cor:99999999999. Given at mount,
mergerfs aborted. Set at runtime through .mergerfs, the daemon shut
down and the mount went away, or with process-thread-count>0 the
request never got a reply. Parse with str::from, which reports the
overflow, and reject the value like any other malformed one.
- Reject a readdir queue depth whose product with the concurrency
overflows an int, e.g. cor:2147483647:2147483647, instead of
wrapping it.
- Limit read-thread-count, process-thread-count and the cor/cosr pool
size to 64 threads per pool, after resolving automatic and
CPU-divided counts, and log a warning when clamping. Resolve
negative FUSE counts without overflowing on INT_MIN, and drop the
unreachable negative readdir concurrency branch.
- process-thread-queue-depth is multiplied by the process thread count.
Saturate the product at INT_MAX instead of overflowing.
- Correct the docs: cor/cosr counts accept digits only and 0 means the
core count, at most 8; a queue depth of 0 means 2 per thread;
read-thread-count=0 with process-thread-count=0 is 2 read threads
and max(2, cores - 2) process threads, at most 8; the queue limit is
depth times process threads, each read thread holding one in-flight
buffer of its own. Point at threads.md for how the settings combine.
- Document the per-read-thread /dev/fuse clones and their fallback.
- tests.cpp covers the overflow cases.
Performance: default thread counts are unchanged (8 on hosts with 8 or
more cores). Only explicit or CPU-divided counts above 64, which
2.42.0 honored, are reduced.
setattr inlined a copy of the helper getattr uses. Call it instead.
Unlike getattr, setattr does not turn a vanished node into ESTALE, so
the helper's result is ignored there, as before.
The mergerfs-fusermount and mount.mergerfs rules ignored CPPFLAGS, and
the fusermount rule also ignored LDFLAGS, so the setuid helper was
built without the distribution's _FORTIFY_SOURCE and relro/now
hardening. Use both in both rules.
- The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the
static archives and the container image still build with NDEBUG=1,
which therefore selected the debug profile: -O0 -g3 with assertions
on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the
debug profile defines DEBUG. The vendored libfuse follows the same
profile as mergerfs.
- make release first removes the objects, binaries and stamp under
build/ and cleans vendored/libfuse, because make only compares
timestamps: objects from an earlier debug build were otherwise
linked into the release binary unchanged. Packages and build reports
in build/pkgs are kept; TEST_release_pkg_preservation checks both.
- make release also builds preload.so. It takes the release defines
through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add
_FILE_OFFSET_BITS=64, which would hide its unsuffixed
open/openat/fopen/creat interposers.
- mergerfs.spec builds the release target, as debian/rules does. The
distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply.
- The release driver mounts the repository with ":ro,z", not ":ro:z",
which Podman read as an extra field instead of a mount option.
TEST_release_metadata runs the driver against a fake podman and
checks the volume argument and the build report.
- Remove release-installer: build-release has no installer target.
- make help printed a literal "\n" where /bin/sh is bash. Match the
build.md transcript to its output and document the profiles.
Performance: static archives and the container image go from -O0 with
assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2
-DNDEBUG). RPM packages keep the distribution's -O2 and no longer
evaluate assertions. A plain make is unoptimized, as before.
Once a file or directory is removed (unlink, rmdir, rename over it)
libfuse has no path for its node and falls back to the fh based
getattr/setattr/statx with fh=0. If mergerfs had no open file for the
node (a directory, an O_PATH fd, a cwd, or a dentry resolved just
before the removal) it returned EBADF. The kernel sends GETATTR for
such nodes in the permission checks of a path walk, so lstat() of a
directory, or of a path below it, could fail with EBADF while rm -rf
removed it. Two rm -rf at once, one on a directory and one on the
directory above it, met it when one removed a directory the other
still had open: the other's unlinkat() through its dirfd failed, rm
reported "Bad file descriptor" and left entries behind.
mergerfs now returns ENOENT. That is what a local filesystem gives
*at() calls in a removed directory, and what rm -f ignores. ESTALE
would make the kernel redo a path based lookup, which helps a stat
racing a rename over the path. But a call through a dirfd or cwd of a
removed directory meets the same node again and fails anyway, and the
concurrent rm -rf still did. Calls on the removed object itself, which
succeed on a local filesystem, get ENOENT instead of EBADF.
TEST_rm_rf_concurrent runs the two cases reported. The rm -rf one is
a narrow race; TEST_use_dirfd_after_rmdir covers its cause without
one, with cache.attr=0 so the kernel sends GETATTR every time.
See #1693.
- DEFERs run in reverse order, so workers posted the semaphore before
setting exited; the main loop could wake, see exited == 0 and wait
again. With one read thread mergerfs then stayed running after
unmount until signaled.
- Set exited and post in a single DEFER, in that order.
- Store cloned read-worker fds on fuse_session and close them there.
- Set up clone fallback through session helpers used by the loop.
- Carry per-request fds through receive, process, and reply paths.
Tests show significant performance increases in highly concurrent
workloads on a high core count system. Upto 15% better on reads and
27% on writes.
- Guard fuse_cfg_t log file and filepath shared pointers with a shared mutex
- Replace atomic shared pointer loads and stores with shared and unique locks
- Add helpers that release path locks and update node state under f.lock.
- Update getattr and setattr stat-cache invalidation while preserving ESTALE handling.
- Rework create, open, tmpfile, and set_path_info to mutate lookup/open state under the shared lock.
- Document the lock/unlock pair as an acquire/release barrier.
- Explain that releasedir waits for in-flight readdir calls before destroy/free.
- Warn against removing the synchronization despite it not being a critical section.
Important changes:
- Switch mergerfs and vendored libfuse Makefiles to -std=c++20.
- Select the latest available GCC/G++ or toolset in container builds.
- Verify compiler C++20 support during package installation.
- Fix dynamic SysLog formatting for fmt C++20 checks.
- Reserve a zero stat CRC to represent an invalid cache fingerprint.
- Include device, size, inode, mtime, and ctime data in the fingerprint.
- Recompute the fingerprint during auto-cache open before keeping cache.
No functional change: libfuse/helper.cpp (fuse_daemonize,
fuse_helper_opt_proc, fuse_parse_cmdline) and mergerfs
fuse_init.cpp (_want helpers) reformatted to match the project's
GNU-style brace placement and aligned parameter lists.
- fuse_opt: reformat process_opt_param to project style; return the
rv from sscanf through a named local so the error branch prints
the failing option cleanly.
- cpu.cpp: when parsing /sys/devices/system/cpu/*/topology/core_id,
bail out cleanly on stream read failure rather than recording an
uninitialized core_id.
- fusermount: free(copy) on the success path of parsing the mount
option (previously leaked on every mount), and replace the fixed-
buffer sprintf into procfile with snprintf bounded by the buffer
size.
- maintenance_thread: widen the iteration count from int to u64
so a long-lived daemon doesn't wrap after ~68 years of ticks
(real effect: silence signed-overflow warnings under UBSan).
- ThreadPool::destroy used to iterate _threads directly while another
thread could be adjusting the same vector. Snapshot the vector
under the mutex and iterate the local copy for pthread_cancel /
pthread_join.
- ObjPool::construct now returns NULL when the pooled allocator
returns NULL instead of invoking placement-new on a null
pointer. In destroy, compute to_node(obj) before running the
destructor - the destructor may scrub bytes the to_node helper
reads.
- In the async/sync workers in fuse_loop, msgbuf_alloc can return
NULL under memory pressure. Fail the worker cleanly with a
diagnostic rather than dereferencing. Also introduce a small
_nproc() helper that treats hardware_concurrency()==0 as 1, so
the downstream min/max arithmetic doesn't produce a zero thread
count.
The signal handler reads the global session pointer from an async-
signal context while another thread installs/removes the session
via set/remove_signal_handlers. Use std::atomic<fuse_session*> with
acquire/release ordering so the handler either sees NULL or a fully
published session, never a torn pointer.
Collapse get_node/get_node_nocheck into a single function that
returns NULL when the node is absent rather than abort()ing.
Callers that previously assumed non-NULL now check the return value
and either reply ESTALE/ENOMEM or fall through gracefully; a few
places where the node is load-bearing (e.g. unhash during remove)
use fatal::abort with a descriptive message.
Switch mutex_lock / mutex_unlock pairs to mutex_lockguard so early
returns on error paths no longer leak the lock, and add NULL-safety
around fuse_dh in readdir/readdir_plus, fuse_dirents_init error
returns, the getattr path when both name and fh are empty, and the
msgbuf allocation in fuse_lib_read.
Pull the new xstrdup/xmalloc wrappers from xalloc.hpp for the root
node name so the common-case OOM path terminates with a diagnostic
instead of a silent corrupted node.
Also guard fuse_session_destroy against a NULL session - called
from error-recovery paths.
The low-level init/destroy callbacks were passed a userdata pointer
that mergerfs never consumed - the caller threaded it through
fuse_lowlevel_new only to hand it back unchanged. Remove the
parameter from the ops struct, from fuse_lowlevel_new(_common),
and from the internal fuse_ll struct; update fuse_lib_init and
fuse_lib_destroy accordingly.
Also drop fuse_reply_ioctl_iov: no caller in-tree invokes it and
the public API is defined by this vendored libfuse fork.
libfuse previously initialized its debug log filepath to
"/dev/stderr", forcing the config layer to reopen stderr on every
load whether or not the user asked for it. Default the libfuse log
path to "" and have the mergerfs config layer only forward the
request to libfuse when the user supplied an explicit path.