allow setting of 'max_pages' (via 'fuse_msg_size')

Linux 4.20 and above allow setting the number of pages per FUSE message
upto 256 (4K * 256 = 1MiB). This can greatly increase read and write
speeds depending on the workload.
This commit is contained in:
Antonio SJ Musumeci 2019-05-30 18:59:18 -04:00
parent 24af276542
commit 7cbd88ac81
14 changed files with 345 additions and 210 deletions

View file

@ -53,6 +53,7 @@ Config::Config()
cache_readdir(false),
async_read(true),
cache_files(CacheFiles::LIBFUSE),
fuse_msg_size(FUSE_MAX_MAX_PAGES),
POLICYINIT(access),
POLICYINIT(chmod),
POLICYINIT(chown),

View file

@ -113,6 +113,7 @@ public:
bool cache_readdir;
bool async_read;
CacheFiles cache_files;
uint16_t fuse_msg_size;
public:
const Policy *policies[FuseFunc::Enum::END];

View file

@ -233,6 +233,18 @@ namespace l
attrvalue_ = (string)cache_files_;
}
static
void
getxattr_controlfile(const uint16_t &uint16_,
string &attrvalue_)
{
std::ostringstream os;
os << uint16_;
attrvalue_ = os.str();
}
static
void
getxattr_controlfile_policies(const Config &config,
@ -358,6 +370,8 @@ namespace l
l::getxattr_controlfile_bool(config.posix_acl,attrvalue);
else if(attr[2] == "async_read")
l::getxattr_controlfile_bool(config.async_read,attrvalue);
else if(attr[2] == "fuse_msg_size")
l::getxattr_controlfile(config.fuse_msg_size,attrvalue);
break;
case 4:

View file

@ -60,6 +60,22 @@ namespace l
*want_ = false;
}
static
void
want_if_capable_max_pages(fuse_conn_info *conn_,
Config &c_)
{
if(l::capable(conn_,FUSE_CAP_MAX_PAGES))
{
l::want(conn_,FUSE_CAP_MAX_PAGES);
conn_->max_pages = c_.fuse_msg_size;
}
else
{
c_.fuse_msg_size = FUSE_DEFAULT_MAX_PAGES_PER_REQ;
}
}
}
namespace FUSE
@ -80,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_max_pages(conn_,c);
return &c;
}

View file

@ -56,6 +56,7 @@ namespace l
("user.mergerfs.cache.symlinks")
("user.mergerfs.direct_io")
("user.mergerfs.dropcacheonclose")
("user.mergerfs.fuse_msg_size")
("user.mergerfs.ignorepponrename")
("user.mergerfs.link_cow")
("user.mergerfs.minfreespace")

View file

@ -102,6 +102,28 @@ set_default_options(fuse_args *args)
set_option(args,"default_permissions");
}
static
int
parse_and_process(const std::string &value_,
uint16_t &uint16_,
uint16_t min_,
uint16_t max_)
{
int rv;
uint64_t uint64;
rv = num::to_uint64_t(value_,uint64);
if(rv == -1)
return 1;
if((uint64 > max_) || (uint64 < min_))
return 1;
uint16_ = uint64;
return 0;
}
static
int
parse_and_process(const std::string &value_,
@ -345,6 +367,10 @@ parse_and_process_kv_arg(Config &config,
rv = parse_and_process(value,config.auto_cache);
else if(key == "async_read")
rv = parse_and_process(value,config.async_read);
else if(key == "fuse_msg_size")
rv = parse_and_process(value,config.fuse_msg_size,
1,
FUSE_MAX_MAX_PAGES);
}
if(rv == -1)