2025-04-08 23:19:21 -05:00
|
|
|
# moveonenospc
|
|
|
|
|
|
|
|
|
|
When writing to a file a [number of
|
|
|
|
|
errors](https://man7.org/linux/man-pages/man2/write.2.html#ERRORS) are
|
|
|
|
|
possible. The `ENOSPC` error indicates their is no room for the
|
|
|
|
|
data. That could be true due to the filesystem having actually no
|
|
|
|
|
available space for data, or because a secondary resource (such as
|
|
|
|
|
inodes) has been used up, or the filesystem might have a quota feature
|
|
|
|
|
that is limiting how much storage a particular user may use, or (as on
|
|
|
|
|
`ext4` there might be a feature which reserves space for privileged
|
|
|
|
|
processes.
|
|
|
|
|
|
|
|
|
|
Since mergerfs [does not offer](../index.md#non-features) splitting of
|
|
|
|
|
files across filesystems there are situations where a file is opened
|
|
|
|
|
or created on a filesystem which is nearly full and eventually
|
|
|
|
|
receives a `ENOSPC` error despite the pool having capacity. The
|
|
|
|
|
`moveonenospc` feature allows the user to have some control over this
|
|
|
|
|
situation.
|
|
|
|
|
|
|
|
|
|
When enabled and a `write` fails with `ENOSPC` or `EDQUOT` mergerfs
|
|
|
|
|
will:
|
|
|
|
|
|
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.
2026-11-22 01:24:45 -05:00
|
|
|
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.
|
2025-04-08 23:19:21 -05:00
|
|
|
2. ["Move"](../faq/technical_behavior_and_limitations.md#how-does-mergerfs-handle-moving-and-copying-of-files)
|
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.
2026-11-22 01:24:45 -05:00
|
|
|
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.
|
2026-11-06 11:24:49 -06:00
|
|
|
3. Retry only the unwritten portion of the request, so a partially
|
|
|
|
|
completed append is not duplicated.
|
2025-04-08 23:19:21 -05:00
|
|
|
|
|
|
|
|
If at any point something fails the progress so far will be cleaned up
|
2026-11-22 01:27:22 -05:00
|
|
|
as appropriate and the original error returned. If part of the write
|
|
|
|
|
already reached the file the bytes written are returned instead, as a
|
2026-11-22 08:27:04 -05:00
|
|
|
short write, as with a local filesystem. The exception is data the
|
|
|
|
|
kernel is flushing from its page cache (`cache.writeback` or dirty
|
|
|
|
|
`mmap` pages). It can't act on a short write, so the error is returned
|
|
|
|
|
and reaches `fsync`, `msync` or `close`.
|
2025-04-08 23:19:21 -05:00
|
|
|
|
2026-11-22 01:27:22 -05:00
|
|
|
If `moveonenospc` is disabled the underlying error will be returned,
|
|
|
|
|
or the bytes written if part of the write succeeded.
|
2025-04-08 23:19:21 -05:00
|
|
|
|
2025-09-21 11:42:15 -05:00
|
|
|
NOTE: This feature has NO effect on policies. It ONLY applies to the
|
2025-04-08 23:19:21 -05:00
|
|
|
literal write function. If the create function returns `ENOSPC` or the
|
|
|
|
|
[policy returns `ENOSPC`](functions_categories_policies.md#filtering)
|
|
|
|
|
that error will be returned back to the application making the
|
|
|
|
|
`create` request.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Additional Reading
|
|
|
|
|
|
|
|
|
|
* [Functions, Categories, Policies](functions_categories_policies.md)
|
|
|
|
|
* [Why do I get an "out of space" / "no space left on device" / ENOSPC
|
|
|
|
|
error even though there appears to be lots of space
|
|
|
|
|
available?](../faq/why_isnt_it_working.md#why-do-i-get-an-out-of-space-no-space-left-on-device-enospc-error-even-though-there-appears-to-be-lots-of-space-available)
|
|
|
|
|
|