mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-19 22:46:34 -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,13 +33,10 @@ namespace epall
|
|||
{
|
||||
static
|
||||
int
|
||||
create(const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
const uint64_t minfreespace_,
|
||||
vector<string> *paths_)
|
||||
create(const BranchVec &branches_,
|
||||
const char *fusepath_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
rwlock::ReadGuard guard(&branches_.lock);
|
||||
|
||||
int rv;
|
||||
int error;
|
||||
fs::info_t info;
|
||||
|
|
@ -50,16 +47,16 @@ namespace epall
|
|||
{
|
||||
branch = &branches_[i];
|
||||
|
||||
if(!fs::exists(branch->path,fusepath_))
|
||||
error_and_continue(error,ENOENT);
|
||||
if(branch->ro_or_nc())
|
||||
error_and_continue(error,EROFS);
|
||||
if(!fs::exists(branch->path,fusepath_))
|
||||
error_and_continue(error,ENOENT);
|
||||
rv = fs::info(branch->path,&info);
|
||||
if(rv == -1)
|
||||
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);
|
||||
|
||||
paths_->push_back(branch->path);
|
||||
|
|
@ -73,12 +70,21 @@ namespace epall
|
|||
|
||||
static
|
||||
int
|
||||
action(const Branches &branches_,
|
||||
create(const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
rwlock::ReadGuard guard(&branches_.lock);
|
||||
rwlock::ReadGuard guard(branches_.lock);
|
||||
|
||||
return epall::create(branches_.vec,fusepath_,paths_);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
action(const BranchVec &branches_,
|
||||
const char *fusepath_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
int rv;
|
||||
int error;
|
||||
bool readonly;
|
||||
|
|
@ -89,10 +95,10 @@ namespace epall
|
|||
{
|
||||
branch = &branches_[i];
|
||||
|
||||
if(!fs::exists(branch->path,fusepath_))
|
||||
error_and_continue(error,ENOENT);
|
||||
if(branch->ro())
|
||||
error_and_continue(error,EROFS);
|
||||
if(!fs::exists(branch->path,fusepath_))
|
||||
error_and_continue(error,ENOENT);
|
||||
rv = fs::statvfs_cache_readonly(branch->path,&readonly);
|
||||
if(rv == -1)
|
||||
error_and_continue(error,ENOENT);
|
||||
|
|
@ -110,12 +116,21 @@ namespace epall
|
|||
|
||||
static
|
||||
int
|
||||
search(const Branches &branches_,
|
||||
action(const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
rwlock::ReadGuard guard(&branches_.lock);
|
||||
rwlock::ReadGuard guard(branches_.lock);
|
||||
|
||||
return epall::action(branches_.vec,fusepath_,paths_);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
search(const BranchVec &branches_,
|
||||
const char *fusepath_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
const Branch *branch;
|
||||
|
||||
for(size_t i = 0, ei = branches_.size(); i != ei; i++)
|
||||
|
|
@ -133,19 +148,29 @@ namespace epall
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
search(const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
rwlock::ReadGuard guard(branches_.lock);
|
||||
|
||||
return epall::search(branches_.vec,fusepath_,paths_);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Policy::Func::epall(const Category type_,
|
||||
const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
const uint64_t minfreespace_,
|
||||
vector<string> *paths_)
|
||||
{
|
||||
switch(type_)
|
||||
{
|
||||
case Category::CREATE:
|
||||
return epall::create(branches_,fusepath_,minfreespace_,paths_);
|
||||
return epall::create(branches_,fusepath_,paths_);
|
||||
case Category::ACTION:
|
||||
return epall::action(branches_,fusepath_,paths_);
|
||||
case Category::SEARCH:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue