From 12cf57dc5a1e10404b93b8fb9b28757712f1f6d9 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Fri, 4 Mar 2016 13:52:31 -0500 Subject: [PATCH] re-add minfreespace check to epmfs policy --- src/policy_epmfs.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/policy_epmfs.cpp b/src/policy_epmfs.cpp index e7c69ae3..4e91948c 100644 --- a/src/policy_epmfs.cpp +++ b/src/policy_epmfs.cpp @@ -16,6 +16,7 @@ #include +#include #include #include @@ -32,13 +33,14 @@ static int _epmfs_create(const vector &basepaths, const char *fusepath, + const size_t minfreespace, vector &paths) { string fullpath; size_t epmfs; const string *epmfsbasepath; - epmfs = 0; + epmfs = std::numeric_limits::min(); epmfsbasepath = NULL; for(size_t i = 0, ei = basepaths.size(); i != ei; i++) { @@ -54,6 +56,8 @@ _epmfs_create(const vector &basepaths, continue; if(readonly) continue; + if(spaceavail < minfreespace) + continue; if(spaceavail < epmfs) continue; @@ -112,10 +116,11 @@ int _epmfs(const Category::Enum::Type type, const vector &basepaths, const char *fusepath, - vector &paths) + const size_t minfreespace, + vector &paths) { if(type == Category::Enum::create) - return _epmfs_create(basepaths,fusepath,paths); + return _epmfs_create(basepaths,fusepath,minfreespace,paths); return _epmfs_other(basepaths,fusepath,paths); } @@ -131,7 +136,7 @@ namespace mergerfs { int rv; - rv = _epmfs(type,basepaths,fusepath,paths); + rv = _epmfs(type,basepaths,fusepath,minfreespace,paths); if(POLICY_FAILED(rv)) rv = Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);