add symlink caching

This commit is contained in:
Antonio SJ Musumeci 2019-05-21 23:23:26 -04:00
parent 9e3331dab4
commit 1baa706d37
11 changed files with 94 additions and 11 deletions

View file

@ -49,6 +49,7 @@ Config::Config()
statfs(StatFS::BASE),
statfs_ignore(StatFSIgnore::NONE),
posix_acl(false),
cache_symlinks(false),
POLICYINIT(access),
POLICYINIT(chmod),
POLICYINIT(chown),

View file

@ -79,6 +79,7 @@ public:
StatFS::Enum statfs;
StatFSIgnore::Enum statfs_ignore;
bool posix_acl;
bool cache_symlinks;
public:
const Policy *policies[FuseFunc::Enum::END];

View file

@ -365,6 +365,8 @@ namespace l
l::getxattr_controlfile_cache_entry(attrvalue);
else if((attr[2] == "cache") && (attr[3] == "negative_entry"))
l::getxattr_controlfile_cache_negative_entry(attrvalue);
else if((attr[2] == "cache") && (attr[3] == "symlinks"))
l::getxattr_controlfile_bool(config.cache_symlinks,attrvalue);
break;
}

View file

@ -21,12 +21,29 @@
namespace l
{
static
void
want(fuse_conn_info *conn_,
const int flag_)
{
conn_->want |= flag_;
}
static
bool
capable(fuse_conn_info *conn_,
const int flag_)
{
return (conn_->capable & flag_);
}
static
void
want_if_capable(fuse_conn_info *conn_,
const int flag_)
{
if(conn_->capable & flag_)
conn_->want |= flag_;
if(capable(conn_,flag_))
want(conn_,flag_);
}
}
@ -35,6 +52,8 @@ namespace FUSE
void *
init(fuse_conn_info *conn_)
{
Config &c = Config::get_writable();
ugid::init();
l::want_if_capable(conn_,FUSE_CAP_ASYNC_READ);
@ -44,9 +63,17 @@ namespace FUSE
l::want_if_capable(conn_,FUSE_CAP_IOCTL_DIR);
l::want_if_capable(conn_,FUSE_CAP_ASYNC_DIO);
l::want_if_capable(conn_,FUSE_CAP_PARALLEL_DIROPS);
if(Config::get().posix_acl)
l::want_if_capable(conn_,FUSE_CAP_POSIX_ACL);
return &Config::get_writable();
if(c.posix_acl && l::capable(conn_,FUSE_CAP_POSIX_ACL))
l::want(conn_,FUSE_CAP_POSIX_ACL);
else
c.posix_acl = false;
if(c.cache_symlinks && l::capable(conn_,FUSE_CAP_CACHE_SYMLINKS))
l::want(conn_,FUSE_CAP_CACHE_SYMLINKS);
else
c.cache_symlinks = false;
return &c;
}
}

View file

@ -50,6 +50,7 @@ namespace l
("user.mergerfs.cache.negative_entry")
("user.mergerfs.cache.open")
("user.mergerfs.cache.statfs")
("user.mergerfs.cache.symlinks")
("user.mergerfs.direct_io")
("user.mergerfs.dropcacheonclose")
("user.mergerfs.ignorepponrename")

View file

@ -239,6 +239,8 @@ parse_and_process_cache(Config &config_,
return (set_kv_option(outargs,"negative_timeout",value_),0);
else if(func_ == "attr")
return (set_kv_option(outargs,"attr_timeout",value_),0);
else if(func_ == "symlinks")
return parse_and_process(value_,config_.cache_symlinks);
return 1;
}
@ -383,6 +385,9 @@ usage(void)
" default = 0 (disabled)\n"
" -o cache.statfs=<int> 'statfs' cache timeout in seconds. Used by\n"
" policies. default = 0 (disabled)\n"
" -o cache.symlinks=<bool>\n"
" enable kernel caching of symlinks (if supported)\n"
" default = false\n"
" -o cache.attr=<int> file attribute cache timeout in seconds.\n"
" default = 1\n"
" -o cache.entry=<int> file name lookup cache timeout in seconds.\n"