make async_read optional again

This commit is contained in:
Antonio SJ Musumeci 2019-05-28 15:15:18 -04:00
parent 40a4762cac
commit ddf6a2f105
10 changed files with 67 additions and 43 deletions

View file

@ -19,12 +19,12 @@
#include "fs.hpp"
#include "rwlock.hpp"
#include <unistd.h>
#include <sys/stat.h>
#include <string>
#include <vector>
#include <unistd.h>
#include <sys/stat.h>
#define MINFREESPACE_DEFAULT (4294967295ULL)
#define POLICYINIT(X) X(policies[FuseFunc::Enum::X])
@ -50,6 +50,8 @@ Config::Config()
statfs_ignore(StatFSIgnore::NONE),
posix_acl(false),
cache_symlinks(false),
cache_readdir(false),
async_read(true),
POLICYINIT(access),
POLICYINIT(chmod),
POLICYINIT(chown),

View file

@ -81,6 +81,7 @@ public:
bool posix_acl;
bool cache_symlinks;
bool cache_readdir;
bool async_read;
public:
const Policy *policies[FuseFunc::Enum::END];

View file

@ -348,6 +348,8 @@ namespace l
l::getxattr_controlfile_bool(config.direct_io,attrvalue);
else if(attr[2] == "posix_acl")
l::getxattr_controlfile_bool(config.posix_acl,attrvalue);
else if(attr[2] == "async_read")
l::getxattr_controlfile_bool(config.async_read,attrvalue);
break;
case 4:

View file

@ -34,7 +34,7 @@ namespace l
capable(fuse_conn_info *conn_,
const int flag_)
{
return (conn_->capable & flag_);
return !!(conn_->capable & flag_);
}
static
@ -45,6 +45,21 @@ namespace l
if(capable(conn_,flag_))
want(conn_,flag_);
}
static
void
want_if_capable(fuse_conn_info *conn_,
const int flag_,
bool *want_)
{
if(*want_ && l::capable(conn_,flag_))
{
l::want(conn_,flag_);
return;
}
*want_ = false;
}
}
namespace FUSE
@ -56,23 +71,15 @@ namespace FUSE
ugid::init();
l::want_if_capable(conn_,FUSE_CAP_ASYNC_READ);
l::want_if_capable(conn_,FUSE_CAP_ASYNC_DIO);
l::want_if_capable(conn_,FUSE_CAP_ASYNC_READ,&c.async_read);
l::want_if_capable(conn_,FUSE_CAP_ATOMIC_O_TRUNC);
l::want_if_capable(conn_,FUSE_CAP_BIG_WRITES);
l::want_if_capable(conn_,FUSE_CAP_CACHE_SYMLINKS,&c.cache_symlinks);
l::want_if_capable(conn_,FUSE_CAP_DONT_MASK);
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(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;
l::want_if_capable(conn_,FUSE_CAP_POSIX_ACL,&c.posix_acl);
return &c;
}

View file

@ -44,6 +44,7 @@ namespace l
string xattrs;
const vector<string> strs =
buildvector<string>
("user.mergerfs.async_read")
("user.mergerfs.branches")
("user.mergerfs.cache.attr")
("user.mergerfs.cache.entry")

View file

@ -99,8 +99,6 @@ static
void
set_default_options(fuse_args *args)
{
set_option(args,"atomic_o_trunc");
set_option(args,"big_writes");
set_option(args,"default_permissions");
}
@ -256,6 +254,10 @@ parse_and_process_arg(Config &config,
return 0;
else if(arg == "direct_io")
return (config.direct_io=true,0);
else if(arg == "async_read")
return (config.async_read=true,0);
else if(arg == "sync_read")
return (config.async_read=false,0);
return 1;
}
@ -311,6 +313,10 @@ parse_and_process_kv_arg(Config &config,
rv = parse_and_process(value,config.fsname);
else if(key == "posix_acl")
rv = parse_and_process(value,config.posix_acl);
else if(key == "direct_io")
rv = parse_and_process(value,config.direct_io);
else if(key == "async_read")
rv = parse_and_process(value,config.async_read);
}
if(rv == -1)
@ -444,7 +450,11 @@ usage(void)
" as 'read only' or 'no create'. 'nc' will ignore\n"
" available space for branches tagged as\n"
" 'no create'. default = none\n"
" -o posix_acl=<bool> enable POSIX ACL support\n"
" -o posix_acl=<bool> Enable POSIX ACL support. default = false\n"
" -o async_read=<bool> If disabled or unavailable the kernel will\n"
" ensure there is at most one pending read \n"
" request per file and will attempt to order\n"
" requests by offset. default = true\n"
<< std::endl;
}