mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-25 17:57:41 +08:00
Merge pull request #663 from trapexit/random
only return 1 branch for rand/eprand policies
This commit is contained in:
commit
0b0f0a1b9e
|
@ -253,14 +253,14 @@ If all branches are filtered an error will be returned. Typically **EROFS** or *
|
||||||
| eplfs (existing path, least free space) | Of all the branches on which the relative path exists choose the drive with the least free space. |
|
| eplfs (existing path, least free space) | Of all the branches on which the relative path exists choose the drive with the least free space. |
|
||||||
| eplus (existing path, least used space) | Of all the branches on which the relative path exists choose the drive with the least used space. |
|
| eplus (existing path, least used space) | Of all the branches on which the relative path exists choose the drive with the least used space. |
|
||||||
| epmfs (existing path, most free space) | Of all the branches on which the relative path exists choose the drive with the most free space. |
|
| epmfs (existing path, most free space) | Of all the branches on which the relative path exists choose the drive with the most free space. |
|
||||||
| eprand (existing path, random) | Calls **epall** and then randomizes. |
|
| eprand (existing path, random) | Calls **epall** and then randomizes. Returns 1. |
|
||||||
| erofs | Exclusively return **-1** with **errno** set to **EROFS** (read-only filesystem). |
|
| erofs | Exclusively return **-1** with **errno** set to **EROFS** (read-only filesystem). |
|
||||||
| ff (first found) | Search category: same as **epff**. Action category: same as **epff**. Create category: Given the order of the drives, as defined at mount time or configured at runtime, act on the first one found. |
|
| ff (first found) | Search category: same as **epff**. Action category: same as **epff**. Create category: Given the order of the drives, as defined at mount time or configured at runtime, act on the first one found. |
|
||||||
| lfs (least free space) | Search category: same as **eplfs**. Action category: same as **eplfs**. Create category: Pick the drive with the least available free space. |
|
| lfs (least free space) | Search category: same as **eplfs**. Action category: same as **eplfs**. Create category: Pick the drive with the least available free space. |
|
||||||
| lus (least used space) | Search category: same as **eplus**. Action category: same as **eplus**. Create category: Pick the drive with the least used space. |
|
| lus (least used space) | Search category: same as **eplus**. Action category: same as **eplus**. Create category: Pick the drive with the least used space. |
|
||||||
| mfs (most free space) | Search category: same as **epmfs**. Action category: same as **epmfs**. Create category: Pick the drive with the most available free space. |
|
| mfs (most free space) | Search category: same as **epmfs**. Action category: same as **epmfs**. Create category: Pick the drive with the most available free space. |
|
||||||
| newest | Pick the file / directory with the largest mtime. |
|
| newest | Pick the file / directory with the largest mtime. |
|
||||||
| rand (random) | Calls **all** and then randomizes. |
|
| rand (random) | Calls **all** and then randomizes. Returns 1. |
|
||||||
|
|
||||||
|
|
||||||
#### Defaults ####
|
#### Defaults ####
|
||||||
|
|
|
@ -622,6 +622,7 @@ T{
|
||||||
eprand (existing path, random)
|
eprand (existing path, random)
|
||||||
T}@T{
|
T}@T{
|
||||||
Calls \f[B]epall\f[] and then randomizes.
|
Calls \f[B]epall\f[] and then randomizes.
|
||||||
|
Returns 1.
|
||||||
T}
|
T}
|
||||||
T{
|
T{
|
||||||
erofs
|
erofs
|
||||||
|
@ -667,6 +668,7 @@ T{
|
||||||
rand (random)
|
rand (random)
|
||||||
T}@T{
|
T}@T{
|
||||||
Calls \f[B]all\f[] and then randomizes.
|
Calls \f[B]all\f[] and then randomizes.
|
||||||
|
Returns 1.
|
||||||
T}
|
T}
|
||||||
.TE
|
.TE
|
||||||
.SS Defaults
|
.SS Defaults
|
||||||
|
|
|
@ -25,17 +25,20 @@ using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
int
|
int
|
||||||
Policy::Func::eprand(const Category::Enum::Type type,
|
Policy::Func::eprand(const Category::Enum::Type type_,
|
||||||
const Branches &branches_,
|
const Branches &branches_,
|
||||||
const char *fusepath,
|
const char *fusepath_,
|
||||||
const uint64_t minfreespace,
|
const uint64_t minfreespace_,
|
||||||
vector<const string*> &paths)
|
vector<const string*> &paths_)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv = Policy::Func::epall(type,branches_,fusepath,minfreespace,paths);
|
rv = Policy::Func::epall(type_,branches_,fusepath_,minfreespace_,paths_);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
std::random_shuffle(paths.begin(),paths.end());
|
{
|
||||||
|
std::random_shuffle(paths_.begin(),paths_.end());
|
||||||
|
paths_.resize(1);
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,17 +25,20 @@ using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
int
|
int
|
||||||
Policy::Func::rand(const Category::Enum::Type type,
|
Policy::Func::rand(const Category::Enum::Type type_,
|
||||||
const Branches &branches_,
|
const Branches &branches_,
|
||||||
const char *fusepath,
|
const char *fusepath_,
|
||||||
const uint64_t minfreespace,
|
const uint64_t minfreespace_,
|
||||||
vector<const string*> &paths)
|
vector<const string*> &paths_)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv = Policy::Func::all(type,branches_,fusepath,minfreespace,paths);
|
rv = Policy::Func::all(type_,branches_,fusepath_,minfreespace_,paths_);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
std::random_shuffle(paths.begin(),paths.end());
|
{
|
||||||
|
std::random_shuffle(paths_.begin(),paths_.end());
|
||||||
|
paths_.resize(1);
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user