mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 23:16:27 -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
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
Copyright (c) 2025, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
@ -17,76 +17,7 @@
|
|||
#include "fuse_utimens.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "errno.hpp"
|
||||
#include "fs_lutimens.hpp"
|
||||
#include "fs_path.hpp"
|
||||
#include "policy_rv.hpp"
|
||||
#include "ugid.hpp"
|
||||
|
||||
#include "fuse.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
static
|
||||
void
|
||||
_utimens_loop_core(const fs::path &basepath_,
|
||||
const fs::path &fusepath_,
|
||||
const timespec ts_[2],
|
||||
PolicyRV *prv_)
|
||||
{
|
||||
int rv;
|
||||
fs::path fullpath;
|
||||
|
||||
fullpath = basepath_ / fusepath_;
|
||||
|
||||
rv = fs::lutimens(fullpath,ts_);
|
||||
|
||||
prv_->insert(rv,basepath_);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_utimens_loop(const std::vector<Branch*> &branches_,
|
||||
const fs::path &fusepath_,
|
||||
const timespec ts_[2],
|
||||
PolicyRV *prv_)
|
||||
{
|
||||
for(auto &branch : branches_)
|
||||
{
|
||||
::_utimens_loop_core(branch->path,fusepath_,ts_,prv_);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_utimens(const Policy::Action &utimensPolicy_,
|
||||
const Policy::Search &getattrPolicy_,
|
||||
const Branches &branches_,
|
||||
const fs::path &fusepath_,
|
||||
const timespec ts_[2])
|
||||
{
|
||||
int rv;
|
||||
PolicyRV prv;
|
||||
std::vector<Branch*> branches;
|
||||
|
||||
rv = utimensPolicy_(branches_,fusepath_,branches);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
::_utimens_loop(branches,fusepath_,ts_,&prv);
|
||||
if(prv.errors.empty())
|
||||
return 0;
|
||||
if(prv.successes.empty())
|
||||
return prv.errors[0].rv;
|
||||
|
||||
branches.clear();
|
||||
rv = getattrPolicy_(branches_,fusepath_,branches);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
return prv.get_error(branches[0]->path);
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::utimens(const fuse_req_ctx_t *ctx_,
|
||||
|
|
@ -95,9 +26,5 @@ FUSE::utimens(const fuse_req_ctx_t *ctx_,
|
|||
{
|
||||
const fs::path fusepath{fusepath_};
|
||||
|
||||
return ::_utimens(cfg.func.utimens.policy,
|
||||
cfg.func.getattr.policy,
|
||||
cfg.branches,
|
||||
fusepath,
|
||||
ts_);
|
||||
return cfg.utimens(cfg.branches,fusepath,ts_);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue