moveonenospc: enhance the feature to allow using a policy

Just like functions you can now set a policy for moveonfreenospc. This
allows for more flexibility.

For backwards compatibility moveonfreenospc=true is converted to
moveonfreenospc=mfs.

minfreespace does apply which is slightly different from original behavior.
This commit is contained in:
Antonio SJ Musumeci 2020-07-12 14:03:14 -04:00
parent f2d4fbfdb2
commit 08d267fc61
23 changed files with 483 additions and 148 deletions

View file

@ -28,22 +28,24 @@ namespace l
uint64_t size_)
{
int64_t rv;
uint64_t len;
uint64_t nleft;
int64_t src_off;
int64_t dst_off;
src_off = 0;
dst_off = 0;
len = size_;
nleft = size_;
do
{
rv = fs::copy_file_range(src_fd_,&src_off,dst_fd_,&dst_off,len,0);
rv = fs::copy_file_range(src_fd_,&src_off,dst_fd_,&dst_off,nleft,0);
if((rv == -1) && (errno == EINTR))
continue;
if(rv == -1)
return -1;
len -= rv;
nleft -= rv;
}
while((len > 0) && (rv > 0));
while(nleft > 0);
return size_;
}