fix: leave the source branch out before moveonenospc picks a branch

- The source branch was dropped from the create policy's result. ff,
  mfs, lfs, lus and pfrd return a single branch, so when that branch
  was the source nothing was left and the write kept ENOSPC even with
  room elsewhere. That happens when the source has free space by
  statvfs but still returns ENOSPC or EDQUOT: a quota, exhausted
  inodes, full btrfs metadata, or a cached statfs.
- Build the candidate list without the source (matched by device and
  inode, as before) and run the policy on that, so it picks another
  branch. With no candidate left the move is still refused.
- test_fs_movefile_and_open_same_branch now checks that ff relocates
  past a source listed first, by its own path or an alias, and that a
  list made only of the source is refused.

Refuse relocation if a duplicate on another branch could become visible
when the source is removed. Keep non-replacing publication to protect
against a late arrival at the destination. The mounted test checks the
original and duplicate contents, then reopens the file through the pool.
This commit is contained in:
Antonio S. Musumeci 2026-11-22 01:24:45 -05:00
parent db9e991ebd
commit cd0679b01f
6 changed files with 189 additions and 50 deletions

View file

@ -20,9 +20,16 @@ situation.
When enabled and a `write` fails with `ENOSPC` or `EDQUOT` mergerfs
will:
1. Run the policy defined by `moveonenospc` to find a target branch.
1. Check that the file's path is absent on every branch other than the
source and its aliases, including read-only and no-create branches.
If the path already exists (even as a dangling symlink), or a branch
cannot be checked, refuse the move: removing the source could make a
later open find a different file. Otherwise, use the `moveonenospc`
policy to choose a destination from the eligible branches.
2. ["Move"](../faq/technical_behavior_and_limitations.md#how-does-mergerfs-handle-moving-and-copying-of-files)
the file from the source branch to the target branch.
the file from the source branch to the target branch. If another entry
appears at the destination during the copy, the move fails without
overwriting that entry or removing the source.
3. Retry only the unwritten portion of the request, so a partially
completed append is not duplicated.