mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-22 16:06:27 -05:00
add writeback caching
This commit is contained in:
parent
e6c8fa3fad
commit
903d39f968
10 changed files with 103 additions and 17 deletions
|
|
@ -52,6 +52,7 @@ Config::Config()
|
|||
cache_symlinks(false),
|
||||
cache_readdir(false),
|
||||
async_read(true),
|
||||
writeback_cache(false),
|
||||
cache_files(CacheFiles::LIBFUSE),
|
||||
fuse_msg_size(FUSE_MAX_MAX_PAGES),
|
||||
POLICYINIT(access),
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ public:
|
|||
bool cache_symlinks;
|
||||
bool cache_readdir;
|
||||
bool async_read;
|
||||
bool writeback_cache;
|
||||
CacheFiles cache_files;
|
||||
uint16_t fuse_msg_size;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ namespace FUSE
|
|||
l::want_if_capable(conn_,FUSE_CAP_IOCTL_DIR);
|
||||
l::want_if_capable(conn_,FUSE_CAP_PARALLEL_DIROPS);
|
||||
l::want_if_capable(conn_,FUSE_CAP_POSIX_ACL,&c.posix_acl);
|
||||
l::want_if_capable(conn_,FUSE_CAP_WRITEBACK_CACHE,&c.writeback_cache);
|
||||
l::want_if_capable_max_pages(conn_,c);
|
||||
|
||||
return &c;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,21 @@ typedef Config::CacheFiles CacheFiles;
|
|||
|
||||
namespace l
|
||||
{
|
||||
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
|
||||
open_core(const string &basepath_,
|
||||
|
|
@ -122,6 +137,9 @@ namespace FUSE
|
|||
break;
|
||||
}
|
||||
|
||||
if(config.writeback_cache)
|
||||
ffi_->flags = l::tweak_flags_writeback_cache(ffi_->flags);
|
||||
|
||||
return l::open(config.open,
|
||||
config.open_cache,
|
||||
config.branches,
|
||||
|
|
|
|||
|
|
@ -281,6 +281,8 @@ parse_and_process_cache(Config &config_,
|
|||
return parse_and_process(value_,config_.cache_readdir);
|
||||
else if(func_ == "files")
|
||||
return parse_and_process(value_,config_.cache_files);
|
||||
else if(func_ == "writeback")
|
||||
return parse_and_process(value_,config_.writeback_cache);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -461,6 +463,10 @@ usage(void)
|
|||
" * full: Keep cache on file open\n"
|
||||
" * auto-full: Keep cache if mtime & size not changed\n"
|
||||
" default = libfuse\n"
|
||||
" -o cache.writeback=<bool>\n"
|
||||
" Enable kernel writeback caching (if supported)\n"
|
||||
" cache.files must must be enabled as well.\n"
|
||||
" default = false\n"
|
||||
" -o cache.symlinks=<bool>\n"
|
||||
" Enable kernel caching of symlinks (if supported)\n"
|
||||
" default = false\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue