mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-21 17:56:42 +08:00
Merge pull request #405 from trapexit/runtime-drop
make dropcacheonclose runtime configurable
This commit is contained in:
commit
25ce9938c6
@ -114,10 +114,10 @@ _getxattr_controlfile_minfreespace(const Config &config,
|
||||
|
||||
static
|
||||
void
|
||||
_getxattr_controlfile_moveonenospc(const Config &config,
|
||||
string &attrvalue)
|
||||
_getxattr_controlfile_bool(bool boolvalue,
|
||||
string &attrvalue)
|
||||
{
|
||||
attrvalue = (config.moveonenospc ? "true" : "false");
|
||||
attrvalue = (boolvalue ? "true" : "false");
|
||||
}
|
||||
|
||||
static
|
||||
@ -175,7 +175,9 @@ _getxattr_controlfile(const Config &config,
|
||||
else if(attr[2] == "minfreespace")
|
||||
_getxattr_controlfile_minfreespace(config,attrvalue);
|
||||
else if(attr[2] == "moveonenospc")
|
||||
_getxattr_controlfile_moveonenospc(config,attrvalue);
|
||||
_getxattr_controlfile_bool(config.moveonenospc,attrvalue);
|
||||
else if(attr[2] == "dropcacheonclose")
|
||||
_getxattr_controlfile_bool(config.dropcacheonclose,attrvalue);
|
||||
else if(attr[2] == "policies")
|
||||
_getxattr_controlfile_policies(config,attrvalue);
|
||||
else if(attr[2] == "version")
|
||||
|
@ -46,6 +46,7 @@ _listxattr_controlfile(char *list,
|
||||
("user.mergerfs.srcmounts")
|
||||
("user.mergerfs.minfreespace")
|
||||
("user.mergerfs.moveonenospc")
|
||||
("user.mergerfs.dropcacheonclose")
|
||||
("user.mergerfs.policies")
|
||||
("user.mergerfs.version")
|
||||
("user.mergerfs.pid");
|
||||
|
@ -126,11 +126,11 @@ _split_attrval(const string &attrval,
|
||||
|
||||
static
|
||||
int
|
||||
_setxattr_srcmounts(vector<string> &srcmounts,
|
||||
_setxattr_srcmounts(const string &attrval,
|
||||
const int flags,
|
||||
vector<string> &srcmounts,
|
||||
pthread_rwlock_t &srcmountslock,
|
||||
const string &destmount,
|
||||
const string &attrval,
|
||||
const int flags)
|
||||
const string &destmount)
|
||||
{
|
||||
string instruction;
|
||||
string values;
|
||||
@ -162,16 +162,16 @@ _setxattr_srcmounts(vector<string> &srcmounts,
|
||||
|
||||
static
|
||||
int
|
||||
_setxattr_minfreespace(Config &config,
|
||||
const string &attrval,
|
||||
const int flags)
|
||||
_setxattr_uint64_t(const string &attrval,
|
||||
const int flags,
|
||||
uint64_t &uint)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if((flags & XATTR_CREATE) == XATTR_CREATE)
|
||||
return -EEXIST;
|
||||
|
||||
rv = num::to_uint64_t(attrval,config.minfreespace);
|
||||
rv = num::to_uint64_t(attrval,uint);
|
||||
if(rv == -1)
|
||||
return -EINVAL;
|
||||
|
||||
@ -180,24 +180,23 @@ _setxattr_minfreespace(Config &config,
|
||||
|
||||
static
|
||||
int
|
||||
_setxattr_moveonenospc(Config &config,
|
||||
const string &attrval,
|
||||
const int flags)
|
||||
_setxattr_bool(const string &attrval,
|
||||
const int flags,
|
||||
bool &value)
|
||||
{
|
||||
if((flags & XATTR_CREATE) == XATTR_CREATE)
|
||||
return -EEXIST;
|
||||
|
||||
if(attrval == "false")
|
||||
config.moveonenospc = false;
|
||||
value = false;
|
||||
else if(attrval == "true")
|
||||
config.moveonenospc = true;
|
||||
value = true;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int
|
||||
_setxattr_controlfile_func_policy(Config &config,
|
||||
@ -251,19 +250,23 @@ _setxattr_controlfile(Config &config,
|
||||
{
|
||||
case 3:
|
||||
if(attr[2] == "srcmounts")
|
||||
return _setxattr_srcmounts(config.srcmounts,
|
||||
return _setxattr_srcmounts(attrval,
|
||||
flags,
|
||||
config.srcmounts,
|
||||
config.srcmountslock,
|
||||
config.destmount,
|
||||
attrval,
|
||||
flags);
|
||||
config.destmount);
|
||||
else if(attr[2] == "minfreespace")
|
||||
return _setxattr_minfreespace(config,
|
||||
attrval,
|
||||
flags);
|
||||
return _setxattr_uint64_t(attrval,
|
||||
flags,
|
||||
config.minfreespace);
|
||||
else if(attr[2] == "moveonenospc")
|
||||
return _setxattr_moveonenospc(config,
|
||||
attrval,
|
||||
flags);
|
||||
return _setxattr_bool(attrval,
|
||||
flags,
|
||||
config.moveonenospc);
|
||||
else if(attr[2] == "dropcacheonclose")
|
||||
return _setxattr_bool(attrval,
|
||||
flags,
|
||||
config.dropcacheonclose);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
Loading…
x
Reference in New Issue
Block a user