mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-19 22:46:34 -05:00
Change getattr and statx to bespoke policies
* Provides: slight improvement in performance as it no longer will need to find and then act on the files. * It doesn't make sense to support all original policy types. Most people used 'newest' or 'ff' and 'combine' is a better default which has same runtime as 'newest' but with better output.
This commit is contained in:
parent
965e26989c
commit
b3b8e793f9
145 changed files with 3803 additions and 1192 deletions
81
src/func_statx_cdco.cpp
Normal file
81
src/func_statx_cdco.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#include "func_statx_cdco.hpp"
|
||||
|
||||
#include "error.hpp"
|
||||
#include "fs_inode.hpp"
|
||||
#include "fs_statx.hpp"
|
||||
#include "symlinkify.hpp"
|
||||
#include "timespec_utils.hpp"
|
||||
|
||||
|
||||
std::string_view
|
||||
Func2::StatxCDCO::name() const
|
||||
{
|
||||
return "cdco";
|
||||
}
|
||||
|
||||
int
|
||||
Func2::StatxCDCO::operator()(const Branches &branches_,
|
||||
const fs::path &fusepath_,
|
||||
const u32 flags_,
|
||||
const u32 mask_,
|
||||
struct fuse_statx *st_,
|
||||
const FollowSymlinksEnum follow_symlinks_,
|
||||
const s64 symlinkify_timeout_)
|
||||
{
|
||||
int rv;
|
||||
Err err;
|
||||
fs::path fullpath;
|
||||
const Branch *first_branch;
|
||||
|
||||
first_branch = nullptr;
|
||||
for(const auto &branch : branches_)
|
||||
{
|
||||
struct fuse_statx tmp_st;
|
||||
|
||||
fullpath = branch.path / fusepath_;
|
||||
err = rv = fs::statx(AT_FDCWD,
|
||||
fullpath,
|
||||
flags_|AT_SYMLINK_NOFOLLOW,
|
||||
mask_,
|
||||
&tmp_st,
|
||||
follow_symlinks_);
|
||||
if(rv < 0)
|
||||
continue;
|
||||
|
||||
if(!first_branch)
|
||||
{
|
||||
*st_ = tmp_st;
|
||||
first_branch = &branch;
|
||||
continue;
|
||||
}
|
||||
|
||||
// This upgrades the uid:gid because mergerfs now does most
|
||||
// file interaction as root and relies on `default_permissions`
|
||||
// to manage permissions. Want to ensure that root owned files
|
||||
// can't be changed so we treat them all as root owned.
|
||||
if(tmp_st.uid == 0)
|
||||
st_->uid = 0;
|
||||
if(tmp_st.gid == 0)
|
||||
st_->gid = 0;
|
||||
st_->atime = TimeSpec::newest(st_->atime,tmp_st.atime);
|
||||
st_->ctime = TimeSpec::newest(st_->ctime,tmp_st.ctime);
|
||||
st_->mtime = TimeSpec::newest(st_->mtime,tmp_st.mtime);
|
||||
st_->btime = TimeSpec::newest(st_->btime,tmp_st.btime);
|
||||
st_->nlink += tmp_st.nlink;
|
||||
}
|
||||
|
||||
if(!first_branch)
|
||||
return err;
|
||||
|
||||
if(symlinkify_timeout_ >= 0)
|
||||
{
|
||||
fullpath = first_branch->path / fusepath_;
|
||||
symlinkify::convert_if_can_be_symlink(fullpath,
|
||||
st_,
|
||||
symlinkify_timeout_);
|
||||
}
|
||||
|
||||
fs::inode::calc(first_branch->path,fusepath_,st_);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue