mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 04:46:41 -05:00
fix: don't cache a failed statvfs as a success
- With cache.statfs=N, statvfs_cache set the entry's timestamp before calling statvfs. When that call failed, the failure was returned once and then every caller for the next N seconds got success with the entry's old or zeroed stats, and create policies chose branches from them. - Refresh the entry only when statvfs succeeds. A failure is returned and retried on the next call. - tests.cpp checks that a second lookup of a missing path still fails.
This commit is contained in:
parent
b7203a9247
commit
5a8e0cdc2d
2 changed files with 31 additions and 3 deletions
|
|
@ -90,19 +90,27 @@ fs::statvfs_cache(const std::string &path_,
|
|||
}
|
||||
}
|
||||
|
||||
int rv = 0;
|
||||
std::unique_lock<std::shared_mutex> lk(g_cache_mutex);
|
||||
|
||||
// Only a successful statvfs refreshes the entry. A failure is
|
||||
// returned to the caller and retried on the next call.
|
||||
Element &e = g_cache[path_];
|
||||
if((now - e.time) > g_timeout)
|
||||
{
|
||||
int rv;
|
||||
struct statvfs st;
|
||||
|
||||
rv = fs::statvfs(path_,&st);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
e.time = now;
|
||||
rv = fs::statvfs(path_,&e.st);
|
||||
e.st = st;
|
||||
}
|
||||
|
||||
*st_ = e.st;
|
||||
|
||||
return rv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue