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