mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 21:00:13 -05:00
rename-exdev (opt-in; the default is passthrough) moves a source it cannot rename across branches into a staging tree and publishes a symlink at the destination. This reworks that fallback so a rename either completes or leaves both names as they were. - Staging opens every component relative to a pinned parent with O_NOFOLLOW, requires a daemon-owned staging root, and refuses when the tree can't be trusted. - Staged names are taken without replacement and must be free on every configured branch, not only those holding the source, so a later lookup cannot reach another rename's payload. Over-long names are shortened. Fallback renames are serialized. - Destinations: a compatible existing destination is replaced, kept under a temporary name until every branch is published, and restored if a later branch fails. A destination on a read-only branch, or a no-create one where the link can't be created, is refused before anything moves. Temporary and restore names never replace an entry, and a restore that fails is reported. - An ordinary rename (rename-exdev=passthrough) also refuses with EXDEV when the destination exists on a read-only branch that does not hold the source: that copy could neither be replaced nor removed and would shadow the renamed file there. It is never scheduled for removal either. - The replacement symlink is prepared in a daemon-private directory, its UID and GID are verified through a pinned descriptor, and it is published without replacement, before any source moves. A sticky, world-writable destination directory under Linux protected symlinks is refused. Each prepared link is tracked by identity for cleanup. - Symlink sources are recreated with their original text, owner and times instead of staged, since staging changes where a relative target resolves. Sources of different types on different branches are refused. A hidden source that cannot be removed fails the rename. - libfuse re-parents the kernel's node onto the staged inode, using a name allocated before publication, so open handles and cached dentries keep working and nothing can fail after the rename commits. - Without renameat2 (FreeBSD 14.4 and 15.0, or seccomp), regular files and directories use a portable layout: a fresh daemon-owned wrapper, access gates that mirror the source's parents with the source's GID and its read and execute bits only, and the payload directory inside the last gate. Foreign-owned parents, unsettable group ownership and non-trivial ACLs are refused before the source moves. A namespace the source never entered is removed. A portable directory that can't be restored stays staged with its path logged, and an existing directory destination is refused before a portable source moves: keeping it aside would need the no-replace rename the portable layout lacks. - Document the fallback, its refusals and FreeBSD limits. - TEST_rename_exdev_publication, TEST_rename_exdev_portable and tests.cpp cover publication rollback, shadows, collisions, ownership, sticky directories, mixed source types, a refused portable directory destination and the portable layout through a mounted pool. TEST_rename_exdev_publication keeps its fixture if its tmpfs can't be detached. Performance: an ordinary rename only adds an lstat per read-only branch, and only when one is configured. The fallback adds about two lstats per branch plus the staging work, and fallback renames run one at a time. |
||
|---|---|---|
| .. | ||
| OPTIONS_TEST_PLAN.md | ||
| posix_parity.py | ||
| README.md | ||
| run-tests | ||
| TEST_api_xattr | ||
| TEST_cfg_link_rename_exdev | ||
| TEST_cfg_statfs_ignore | ||
| TEST_cfg_xattr_modes | ||
| TEST_dirents_allocation | ||
| TEST_io_passthrough_create_open | ||
| TEST_io_passthrough_open_race | ||
| TEST_mount_lifecycle | ||
| TEST_movefile_enospc | ||
| TEST_no_fuse_hidden | ||
| TEST_o_direct | ||
| TEST_open_after_unlink | ||
| TEST_policy_lup | ||
| TEST_posix_access | ||
| TEST_posix_bmap | ||
| TEST_posix_chmod | ||
| TEST_posix_chown | ||
| TEST_posix_copy_file_range | ||
| TEST_posix_create_mknod | ||
| TEST_posix_fsync_flush | ||
| TEST_posix_getattr_fgetattr | ||
| TEST_posix_ioctl | ||
| TEST_posix_link_symlink | ||
| TEST_posix_locking | ||
| TEST_posix_mkdir_rmdir | ||
| TEST_posix_open_read_write | ||
| TEST_posix_poll | ||
| TEST_posix_readdir | ||
| TEST_posix_readdir_plus | ||
| TEST_posix_release | ||
| TEST_posix_releasedir | ||
| TEST_posix_statfs | ||
| TEST_posix_statx | ||
| TEST_posix_syncfs | ||
| TEST_posix_tmpfile | ||
| TEST_posix_truncate_ftruncate | ||
| TEST_posix_unlink_rename | ||
| TEST_posix_utimens | ||
| TEST_posix_xattr | ||
| TEST_posix_xattr_matrix | ||
| TEST_preload_fopen_modes | ||
| TEST_readdir_cor_cookie_replay | ||
| TEST_readdir_cor_enomem | ||
| TEST_readlink_semantics | ||
| TEST_release_metadata | ||
| TEST_release_pkg_preservation | ||
| TEST_rename_exdev_portable | ||
| TEST_rename_exdev_publication | ||
| TEST_rm_rf_concurrent | ||
| TEST_rmdir_enotempty_priority | ||
| TEST_teardown_safety | ||
| TEST_unlink_rename | ||
| TEST_use_dirfd_after_rmdir | ||
| TEST_use_fallocate_after_unlink | ||
| TEST_use_fchmod_after_unlink | ||
| TEST_use_fchown_after_unlink | ||
| TEST_use_fstat_after_unlink | ||
| TEST_use_ftruncate_after_unlink | ||
| TEST_use_futimens_after_unlink | ||
| tests.cpp | ||
POSIX Soft Conformance Suite
This directory contains integration tests that exercise mergerfs FUSE operations and compare behavior against equivalent native syscalls on a local filesystem.
The suite is "soft POSIX": it focuses on practical parity for return values,
errno, and key side effects, including common error paths.
Each test mounts its own ephemeral mergerfs instance with random temporary branches and cleans everything up automatically.
Run with:
python3 tests/run-tests
Coverage Matrix
access->TEST_posix_accesschmod/fchmod->TEST_posix_chmod,TEST_use_fchmod_after_unlinkchown/fchown->TEST_posix_chown,TEST_use_fchown_after_unlinkcreate/mknod->TEST_posix_create_mknodgetattr/fgetattr->TEST_posix_getattr_fgetattr,TEST_use_fstat_after_unlinkopen/read/write->TEST_posix_open_read_write,TEST_o_directflush/release/fsync/fsyncdir->TEST_posix_fsync_flushreleaseclose semantics ->TEST_posix_releasereleasedirclose semantics ->TEST_posix_releasedirtruncate/ftruncate->TEST_posix_truncate_ftruncate,TEST_use_ftruncate_after_unlinkutimens/futimens->TEST_posix_utimens,TEST_use_futimens_after_unlinkfallocate->TEST_use_fallocate_after_unlinkcopy_file_range->TEST_posix_copy_file_rangeioctl->TEST_posix_ioctlpoll->TEST_posix_polltmpfile(O_TMPFILE) ->TEST_posix_tmpfilebmap(viaFIBMAPioctl parity) ->TEST_posix_bmapreadlink->TEST_readlink_semanticslink/symlink->TEST_posix_link_symlinkmkdir/rmdir->TEST_posix_mkdir_rmdirunlink/rename->TEST_posix_unlink_rename,TEST_unlink_renamestatfs->TEST_posix_statfsstatx->TEST_posix_statxsyncfs->TEST_posix_syncfsflock/lock->TEST_posix_lockingsetxattr/getxattr/listxattr/removexattr->TEST_posix_xattr- xattr object/flag matrix (
file,dir, symlinkl*, create/replace) ->TEST_posix_xattr_matrix - xattr mode runtime toggles (
passthrough/noattr/nosys) ->TEST_cfg_xattr_modes - statfs mode and statfs-ignore runtime toggles ->
TEST_cfg_statfs_ignore - EXDEV fallback runtime toggles for link/rename ->
TEST_cfg_link_rename_exdev readdir(+ seek/tell behavior) ->TEST_posix_readdirreaddir_plussemantic parity (list+stat and readdir policy toggles) ->TEST_posix_readdir_plus- lifecycle (
init/destroy) harness check ->TEST_mount_lifecycle - hidden temp exposure checks ->
TEST_no_fuse_hidden
Error Conditions Emphasized
Across tests, parity checks include combinations of:
ENOENTENOTDIREEXISTENOTEMPTYEISDIREBADF- privilege-sensitive outcomes (for example
EPERM) where applicable
Notes
- Some behavior is runtime/environment dependent (kernel, mount options, uid/gid, capabilities). Tests compare mergerfs to native behavior in the same runtime to keep assertions robust.
- Tests that cannot exercise a behavior in the current environment may exit 77
and are reported as
SKIPbytests/run-tests. - The xattr test uses a
user.*key and assumes user xattrs are enabled. - Tests mount their own ephemeral mergerfs instances using the
mergerfs_mountcontext manager inposix_parity.py. Random directories are created and cleaned up automatically.