mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 04:46:41 -05:00
fix: keep failed statvfs results in the cache and track entry validity
- A new entry was told apart from a fresh one only by its time of 0. With a timeout at least the current time in seconds, such as cache.statfs=4294967295, a new entry looked fresh before statvfs had run, so the zeroed struct was returned as success: every branch reported no free space and every create failed with ENOSPC, and a nonexistent path succeeded.3735d721applies cache.statfs from the mount options, which made it reachable from fstab. Give the entry a valid flag set by the first statvfs. -5e74822fstopped caching a failure as a success by retrying it on every call, under the exclusive lock. With a branch that fails slowly, such as an unreachable network mount, each caller then waited for its own failure one after the other: eight callers took 2.4s where 2.42.2 took 0.3s. Keep the failure, as an error, for the timeout like a success. It is still never returned as zeroed space. - Read the clock again once the lock is held, so a caller that waited doesn't compute a negative age against the entry another refreshed. - Tests: a failure is kept until the timeout, and timeouts of 4294967295 and UINT64_MAX still return real values and errors. Both fail without this change. Measure age with a steady clock, starting when statvfs returns. Even a refresh slower than the configured timeout can be shared by callers that waited for it; wall-clock adjustments cannot extend its lifetime.
This commit is contained in:
parent
64d3af02a3
commit
898ad5992d
3 changed files with 116 additions and 32 deletions
|
|
@ -118,7 +118,9 @@ A number of policies require looking up the available space of the
|
|||
branches being considered. This is accomplished by calling
|
||||
[statfs](https://man7.org/linux/man-pages/man2/statfs.2.html). This
|
||||
call however is a bit expensive so this cache reduces the overhead by
|
||||
limiting how often the calls are actually made.
|
||||
limiting how often the calls are actually made. Successful and failed
|
||||
lookups are cached for the same timeout. The timeout starts when the
|
||||
lookup finishes and is unaffected by changes to the system clock.
|
||||
|
||||
This will mean that if the available space of branches changed
|
||||
somewhat rapidly there is a risk of `create` or `mkdir` calls made
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue