Commit graph

23 commits

Author SHA1 Message Date
Antonio SJ Musumeci
c49989b75f fix: relocate every handle of a file together, after removing the source
- Relocating only the writer left other opens on the old inode. A later
  write through one of them could succeed and disappear after close and
  reopen through the pool. Every handle of a kernel node, including
  opens made after a rename through mergerfs, now belongs to one group.
  Prepare a replacement descriptor for each handle and switch the group
  together. An open of the file while a relocation runs waits and gets
  the moved file.
- Only a node that can be relocated gets a group: one first opened
  while moveonenospc is enabled and without a kernel passthrough ID,
  which stays on the original file and can't be switched. Every other
  node's handles take no lock. Enabling moveonenospc at runtime
  therefore applies to files opened afterwards.
- The switch dup2s each replacement onto the handle's own descriptor
  number, so a handle's fd never changes while it is open. Operations
  that change the file hold the group's lock shared and wait for a
  move. Reads, flush and fsync take no lock and continue on the
  original, which the copy matches. fgetattr and statx take a second
  lock, which a move holds only from the source unlink until the
  switch, so they never report the unlinked original.
- A copy is not a committed move. Prepare all bindings first, then
  remove the source; if that fails keep every handle on the original,
  clean up the provisional copy when it still denotes this copy, and
  return only bytes actually written. A handle whose descriptor number
  is at or above the descriptor limit refuses the move, the only way
  dup2 could fail after the removal.
- The source was removed before its copy reached disk, so a crash could
  leave the name without its data. fsync the copy and the directories
  leading to it before removing the source, and the source's directory
  after, so on a filesystem that can sync them a crash leaves the
  original or a complete copy and never brings the original back over
  the copy. A failed sync after the removal is logged; the move has
  completed by then. fs::copyfile is split into stage and publish steps
  for this; the staged descriptor pins the copy for preparation and
  cleanup.
- chmod, chown, utimes and xattr changes reach mergerfs by path and
  don't wait for a move. Compare ctime as well as size and mtime, so a
  change during the copy makes it retry and one after it refuses the
  move, rather than being lost with the source.
- The kernel can reach one file through more than one node: a hardlink
  whose other name was removed while both were open, a rename made
  directly on a branch while the file was open, or overlapping
  branches. A move cannot switch another node's handles, which would
  keep writing to the original, so it is refused while any other node
  has the file open. The mover checks the canonical descriptor of every
  open node. That check and the descriptor limit run after the cheaper
  checks, so a full pool doesn't pay for them, and before the copy, so a
  lasting refusal doesn't cost a copy per write; they run again just
  before the unlink. An open through another node that races the move's
  last step is not coordinated with it; moveonenospc.md documents this.
- Also refuse to relocate a file with more than one link or an entry
  in the rename-exdev staging tree. Each handle keeps a valid path
  after the move.
- New shared acquisitions wait while a relocation is pending, so a
  stream of writes to allocated blocks can't starve the mover.
- That wait uses std::atomic wait and notify_all, which libstdc++
  first provides in GCC 11, so GCC 11 is now the oldest GCC that
  builds mergerfs. GCC 10 accepts -std=c++20 and concepts, so
  install-build-pkgs and run-rpmbuild also probe for the atomic
  operations: such a compiler is rejected up front, or run-rpmbuild
  moves on to a newer toolset. build.md names the minimum.
- moveonenospc kept its enable bit and policy in two fields, which
  setxattr changed separately while requests read them. Keep one
  atomic policy pointer where null means disabled, and read it once
  per relocation. tests.cpp covers enabling, disabling and an invalid
  value keeping the previous setting.
- The relocation moves out of fuse_write.cpp into moveonenospc.cpp,
  where one function holds every reason to refuse a move.
  fs::movefile_and_open no longer opens anything and becomes
  fs::movefile, which asks the caller's hooks whether to move and to
  switch its handles.
- Document the group behaviour, durability and refusals in
  moveonenospc.md.
- TEST_movefile_enospc covers preexisting, secondary and read-only
  handles, a hardlinked file, a file open through another node, enabling
  moveonenospc while a file is open, repeated relocation with a handle
  opened between moves, steady writers, concurrent relocation, reads and
  fstat during a copy, a mode change during the copy, and failed source
  removal with and without a written prefix, checking held handles and
  close/reopen contents. Its fixtures truncate the filler before
  unlinking it: a scanner holding the file open kept its space
  allocated, which made the hardlink case fail intermittently.

Performance: a file that can't be relocated, because moveonenospc was
disabled when it was first opened or it has a passthrough ID, takes no
locks and allocates nothing; writes no longer take the per-handle lock
they used to. For a relocatable file, reads, flush and fsync take no
lock. Writes and other operations that change the file take the
group's lock shared, about two uncontended atomic operations, and
fgetattr and statx take the second lock, on its own cache line, the
same way. An ENOSPC write takes the lock exclusively only when a move
is possible. Opening and closing files adds no syscall; the first open
of a relocatable file allocates its group. A relocation adds an fstat
per open file to find other nodes of the file. While a file is being
relocated, operations that change it and new opens of it wait for the
copy, as the writer already did; reads and fstat continue.
2026-11-30 23:49:56 -05:00
Antonio SJ Musumeci
036246140b build: make the release driver and Debian changelogs dependable
- The container release driver wrote rv=fail but returned success to
  CI. Run every selected target, keep its report line, and exit
  nonzero if any target fails or its builder can't run. A missing
  podman during --cleanup is reported per target instead of aborting
  the run. Reject a target name that matches no containerfile.
- --branch silently defaulted to master, and the tarball containerfile
  did too, so a release could package a moving branch instead of the
  intended tag. Require --branch and --git-repo for direct calls.
- Remove the static installer target. Its makeself command printed
  "foo", and it copied whatever static archives the output directory
  held, possibly from an older release or missing one built later in
  the same run. The static archives themselves are unchanged.
- git2debcl enumerated every tag and used symmetric differences, so a
  private tag could become a package version and commits from another
  branch could be listed. Take release and release-candidate tags
  reachable from the requested revision, ordered by version with each
  final after its candidates, with one-sided ranges between ancestor
  boundaries. Keep the requested version when tags share a revision or
  a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a
  shallow tagless checkout must give --version.
- Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg
  orders them below the 2.42.0 final. The raw -rc1 form sorted above
  it, making the final release look like a downgrade.
- TEST_release_metadata covers the driver's results and arguments,
  sibling and merged histories, non-release tags, candidates,
  tagless and shallow checkouts, and dpkg version ordering.
- Document the static and release targets and the driver's arguments.
2026-11-29 23:11:10 -05:00
Antonio SJ Musumeci
181371d84c docs: install the Debian package from its actual output directory
make deb moves the generated binary packages to build/pkgs/. The
documented dpkg command still looked in the parent directory and could
fail or pick up an older artifact.
2026-11-29 23:11:09 -05:00
Antonio SJ Musumeci
d83e01b40a build: select a working C++20 compiler for RPM builds
A compiler activated while installing dependencies does not survive in
the caller's shell, so make rpm could fall back to one that can't
compile mergerfs. Route the RPM build through buildtools/run-rpmbuild,
which keeps an explicit compiler and otherwise activates an installed
GCC Toolset when the default can't handle C++20. RPMBUILD and
RPMBUILD_FLAGS override the rpmbuild command.

Rocky 8's toolsets lack the annobin plugin the distribution's RPM
flags load. Test the effective compiler with the RPM flags and pass
--undefine _annotated_build only when that fails, instead of guessing
from the compiler's path in build-mergerfs. Native and container
builds use the same check.
2026-11-29 23:11:08 -05:00
Antonio SJ Musumeci
844e1acffd docs: limit the Compose mount to the permissions mergerfs needs
The sample enabled privileged mode in addition to passing /dev/fuse
and granting SYS_ADMIN. That exposed unrelated host devices and
capabilities to the container. Remove the blanket grant and keep the
same device, capability and propagation settings as the rootful CLI
example.

Docker's default AppArmor profile denies mount(2), so on hosts where
AppArmor is enforcing the container also needs apparmor=unconfined or
a profile that allows the FUSE mount. Say so rather than restoring
privileged mode.
2026-11-29 23:11:05 -05:00
Antonio SJ Musumeci
cf8c489ae2 docs: fix the runtime interface example and package file names
- getfattr prints the key it was asked for, and the create policies
  the example sets and shows are real ones (pfrd, epmfs), not the
  nonexistent prfd.
- rpmbuild names its output mergerfs-<version>-1.<dist>.<arch>.rpm,
  and the static release archive includes the version in its name.
- --nosignature applies to every distribution that enforces RPM
  signatures, not only Fedora 45.
2026-11-29 23:10:56 -05:00
Antonio SJ Musumeci
4540af2a75 build: keep the compiler handoff and probe files out of /tmp
- install-build-pkgs runs as root and handed its compiler choice to
  build-mergerfs through /tmp/build-env, which another user could
  create before root writes it. Use /etc/mergerfs-build-env, written
  to a temporary name, made mode 0644 and renamed into place, so a
  normal user can source it regardless of root's umask and never reads
  it half written.
- The C++20 probe compiles in a private temporary directory instead of
  at fixed names in /tmp.
- yum hosts also consider an already installed devtoolset, which "yum
  list available" omits.
- Document sourcing the handoff file before make deb.
2026-11-29 23:10:54 -05:00
Antonio SJ Musumeci
3c02e47e47 build: make NDEBUG=1 and make release build the release profile
- 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.
2026-11-29 23:10:53 -05:00
Antonio SJ Musumeci
bdfbedad8b Fix release builds and drop Debian 11 targets
Enable parallel Debian package builds through debhelper, remove Debian 11 release targets, and select the installed GCC Toolset activation script on Rocky Linux 10 while preserving older layouts. Update the build documentation.
2026-11-05 15:02:42 -06:00
Antonio SJ Musumeci
5d5d7af90b Add Fedora 45 and Ubuntu 26.10 build targets 2026-11-02 18:57:58 -06:00
natalefalco
8ea47df13e Include Docker Compose setup for mergerfs
Added Docker Compose configuration for running mergerfs.
2026-07-31 08:13:59 -05:00
shyney7
42ab831d97 docs/setup: link install :z example to SELinux FAQ 2026-05-17 10:14:21 -05:00
trapexit
2ae57642f4
Misc documentation updates (#1612) 2026-01-27 07:00:22 -06:00
trapexit
b6e1a08aef
Add link to container image repo (#1570)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
mkdocs / deploy (push) Waiting to run
2025-11-11 19:38:18 -06:00
trapexit
47bd4259b8
Add container image details (#1569)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled
2025-11-08 20:28:10 -06:00
trapexit
1707dc27e3
Misc doc updates (#1531)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
mkdocs / deploy (push) Waiting to run
2025-09-21 14:25:24 -05:00
trapexit
2b500f194a
Rework of runtime interface (#1498)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled
Also have special error handling for when branches are invalid and
ENOENT would be returned for getattr and readdir so users understand
what is going on and the runtime interface can still be used to fix
the problem.
2025-07-21 18:18:59 -05:00
Zack Guo
5db04b4b5f
Update installation.md for SUSE 2025-05-08 07:44:57 -05:00
Solipsistmonkey
455a81290b
Fix build instructions typo
the location of install-build-pkgs was in buildtools and not tools
---------

Co-authored-by: Jesse Harwin <jesse@jharwin.com>
2025-04-28 14:00:20 -05:00
Antonio SJ Musumeci
3a33a6db2b Add FAQ section on common perceived problems 2025-02-22 22:25:39 -06:00
debian
2aa9697c87 re-order OS, shorten Debian based OS instructions 2025-01-18 01:14:50 +01:00
Antonio SJ Musumeci
b83bd5fd14 Improve FreeBSD compatibility
First draft. Need to investigate why upstream patches include certain
function that appear to exist in FreeBSD 14.2.
2025-01-15 22:10:02 -06:00
Antonio SJ Musumeci
75d7a93724 Rework mkdocs based documentation
Lots of restructoring and extra information.
2025-01-03 12:17:26 -06:00