add writeback caching

This commit is contained in:
Antonio SJ Musumeci 2020-02-07 14:05:03 -05:00
parent e6c8fa3fad
commit 903d39f968
10 changed files with 103 additions and 17 deletions

View file

@ -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,