mergerfs/mkdocs/docs/config/moveonenospc.md
Antonio S. Musumeci 072b07b6d5 fix: report a short write when ENOSPC recovery fails after a prefix
- 78a67fd0 kept the bytes written before ENOSPC when the move worked.
  When it didn't (moveonenospc off, no branch to move to, the move or
  the retry failing, or a non-ENOSPC error), write still returned the
  error and dropped the count, though those bytes were on disk. An
  O_APPEND writer that retried the whole buffer duplicated them.
- Return the bytes written as a short write whenever some reached the
  file, as a local filesystem does. A write that wrote nothing still
  returns the error.
- TEST_movefile_enospc checks it with moveonenospc=false and a write
  bigger than the space left. Document it in moveonenospc.md.
2026-11-22 01:27:22 -05:00

50 lines
2.3 KiB
Markdown

# 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:
1. Run the policy defined by `moveonenospc` to find a target branch.
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.
3. Retry only the unwritten portion of the request, so a partially
completed append is not duplicated.
If at any point something fails the progress so far will be cleaned up
as appropriate and the original error returned. If part of the write
already reached the file the bytes written are returned instead, as a
short write, as with a local filesystem.
If `moveonenospc` is disabled the underlying error will be returned,
or the bytes written if part of the write succeeded.
NOTE: This feature has NO effect on policies. It ONLY applies to the
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)