mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-19 14:36:36 -05:00
branches: add per branch minfreespace w/ original value as default
example: /mnt/disk0=RW,1G:/mnt/disk1=RW,2G
This commit is contained in:
parent
98c49b8001
commit
fc3453932a
68 changed files with 3005 additions and 813 deletions
|
|
@ -33,22 +33,19 @@ namespace lfs
|
|||
{
|
||||
static
|
||||
int
|
||||
create(const Branches &branches_,
|
||||
const uint64_t minfreespace_,
|
||||
vector<string> *paths_)
|
||||
create(const BranchVec &branches_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
rwlock::ReadGuard guard(&branches_.lock);
|
||||
|
||||
int rv;
|
||||
int error;
|
||||
uint64_t lfs;
|
||||
fs::info_t info;
|
||||
const Branch *branch;
|
||||
const string *lfsbasepath;
|
||||
const string *basepath;
|
||||
|
||||
error = ENOENT;
|
||||
lfs = std::numeric_limits<uint64_t>::max();
|
||||
lfsbasepath = NULL;
|
||||
basepath = NULL;
|
||||
for(size_t i = 0, ei = branches_.size(); i != ei; i++)
|
||||
{
|
||||
branch = &branches_[i];
|
||||
|
|
@ -60,33 +57,42 @@ namespace lfs
|
|||
error_and_continue(error,ENOENT);
|
||||
if(info.readonly)
|
||||
error_and_continue(error,EROFS);
|
||||
if(info.spaceavail < minfreespace_)
|
||||
if(info.spaceavail < branch->minfreespace())
|
||||
error_and_continue(error,ENOSPC);
|
||||
if(info.spaceavail > lfs)
|
||||
continue;
|
||||
|
||||
lfs = info.spaceavail;
|
||||
lfsbasepath = &branch->path;
|
||||
basepath = &branch->path;
|
||||
}
|
||||
|
||||
if(lfsbasepath == NULL)
|
||||
if(basepath == NULL)
|
||||
return (errno=error,-1);
|
||||
|
||||
paths_->push_back(*lfsbasepath);
|
||||
paths_->push_back(*basepath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
create(const Branches &branches_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
rwlock::ReadGuard guard(branches_.lock);
|
||||
|
||||
return lfs::create(branches_.vec,paths_);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Policy::Func::lfs(const Category type_,
|
||||
const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
const uint64_t minfreespace_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
if(type_ == Category::CREATE)
|
||||
return lfs::create(branches_,minfreespace_,paths_);
|
||||
return lfs::create(branches_,paths_);
|
||||
|
||||
return Policy::Func::eplfs(type_,branches_,fusepath_,minfreespace_,paths_);
|
||||
return Policy::Func::eplfs(type_,branches_,fusepath_,paths_);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue