mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
add writeback caching
This commit is contained in:
parent
e6c8fa3fad
commit
903d39f968
10 changed files with 103 additions and 17 deletions
|
|
@ -35,6 +35,30 @@ typedef Config::CacheFiles CacheFiles;
|
|||
|
||||
namespace l
|
||||
{
|
||||
/*
|
||||
The kernel expects being able to issue read requests when running
|
||||
with writeback caching enabled so we must change O_WRONLY to
|
||||
O_RDWR.
|
||||
|
||||
With writeback caching enabled the kernel handles O_APPEND. Could
|
||||
be an issue if the underlying file changes out of band but that is
|
||||
true of any caching.
|
||||
*/
|
||||
static
|
||||
int
|
||||
tweak_flags_writeback_cache(const int flags_)
|
||||
{
|
||||
int flags;
|
||||
|
||||
flags = flags_;
|
||||
if((flags & O_ACCMODE) == O_WRONLY)
|
||||
flags = ((flags & ~O_ACCMODE) | O_RDWR);
|
||||
if(flags & O_APPEND)
|
||||
flags &= ~O_APPEND;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
create_core(const string &fullpath_,
|
||||
|
|
@ -153,6 +177,9 @@ namespace FUSE
|
|||
break;
|
||||
}
|
||||
|
||||
if(config.writeback_cache)
|
||||
ffi_->flags = l::tweak_flags_writeback_cache(ffi_->flags);
|
||||
|
||||
return l::create(config.getattr,
|
||||
config.create,
|
||||
config.branches,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue