Browse Source

make dropcacheonclose runtime configurable

pull/405/head
Antonio SJ Musumeci 8 years ago
parent
commit
8ba3a08f40
  1. 10
      src/getxattr.cpp
  2. 1
      src/listxattr.cpp
  3. 51
      src/setxattr.cpp

10
src/getxattr.cpp

@ -114,10 +114,10 @@ _getxattr_controlfile_minfreespace(const Config &config,
static static
void 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 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")

1
src/listxattr.cpp

@ -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");

51
src/setxattr.cpp

@ -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 &attrval,
const int flags)
const string &destmount)
{ {
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,
const string &attrval,
const int flags)
_setxattr_uint64_t(const string &attrval,
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,
const string &attrval,
const int flags)
_setxattr_bool(const string &attrval,
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,
attrval,
flags);
config.destmount);
else if(attr[2] == "minfreespace") else if(attr[2] == "minfreespace")
return _setxattr_minfreespace(config,
attrval,
flags);
return _setxattr_uint64_t(attrval,
flags,
config.minfreespace);
else if(attr[2] == "moveonenospc") 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; break;
case 4: case 4:

Loading…
Cancel
Save