mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-03 05:10:14 -05:00
fix: make the statfs cache correct and its timeout configurable
- A failed statvfs was cached as a success: for the next cache.statfs seconds every caller got the entry's old or zeroed stats and create policies chose branches from them. Keep a failure as an error for the timeout, like a success, so a slow failing branch isn't retried under the lock by every caller in turn. Document that the branch then stays excluded from space-based create policies until the timeout expires. - A new entry was told apart from a fresh one only by a time of 0, so a timeout of at least the current time in seconds returned the zeroed struct as success. Give entries a valid flag set by the first statvfs, and measure age with a steady clock from when statvfs returned. - cache.statfs given at mount was stored but never applied. Bind the option directly to the atomic the cache reads, so mount options, config files and control-file updates follow one path and concurrent readback no longer races with updates. - tests.cpp checks that a cached failure is never served as success, that failures are kept until the timeout, huge timeouts, an invalid update keeping a cached ENOENT, and a timeout of 0 exposing a newly created directory immediately.
This commit is contained in:
parent
844e1acffd
commit
b367b593ba
8 changed files with 152 additions and 48 deletions
|
|
@ -118,7 +118,14 @@ 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. A cached failure therefore
|
||||
keeps the branch excluded from space-based create policies until the
|
||||
timeout expires, even if the branch recovers sooner. The timeout
|
||||
starts when the lookup finishes and is unaffected by changes to the
|
||||
system clock.
|
||||
Changing `cache.statfs` at runtime applies directly to subsequent policy
|
||||
lookups; setting it to `0` bypasses cached results.
|
||||
|
||||
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