mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
set direct_io per open/create, now runtime configurable
This commit is contained in:
parent
c36bc5320d
commit
87b2795f2b
12 changed files with 336 additions and 334 deletions
92
src/open.cpp
92
src/open.cpp
|
|
@ -14,8 +14,6 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <fuse.h>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "errno.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
|
|
@ -25,58 +23,63 @@
|
|||
#include "rwlock.hpp"
|
||||
#include "ugid.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <fuse.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using mergerfs::Policy;
|
||||
|
||||
static
|
||||
int
|
||||
_open_core(const string *basepath_,
|
||||
const char *fusepath_,
|
||||
const int flags_,
|
||||
const bool link_cow_,
|
||||
uint64_t &fh_)
|
||||
namespace local
|
||||
{
|
||||
int fd;
|
||||
string fullpath;
|
||||
static
|
||||
int
|
||||
open_core(const string &basepath_,
|
||||
const char *fusepath_,
|
||||
const int flags_,
|
||||
const bool link_cow_,
|
||||
uint64_t *fh_)
|
||||
{
|
||||
int fd;
|
||||
string fullpath;
|
||||
|
||||
fs::path::make(basepath_,fusepath_,fullpath);
|
||||
fs::path::make(basepath_,fusepath_,&fullpath);
|
||||
|
||||
if(link_cow_ && fs::cow::is_eligible(fullpath.c_str(),flags_))
|
||||
fs::cow::break_link(fullpath.c_str());
|
||||
if(link_cow_ && fs::cow::is_eligible(fullpath.c_str(),flags_))
|
||||
fs::cow::break_link(fullpath.c_str());
|
||||
|
||||
fd = fs::open(fullpath,flags_);
|
||||
if(fd == -1)
|
||||
return -errno;
|
||||
fd = fs::open(fullpath,flags_);
|
||||
if(fd == -1)
|
||||
return -errno;
|
||||
|
||||
fh_ = reinterpret_cast<uint64_t>(new FileInfo(fd,fusepath_));
|
||||
*fh_ = reinterpret_cast<uint64_t>(new FileInfo(fd,fusepath_));
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
_open(Policy::Func::Search searchFunc_,
|
||||
const Branches &branches_,
|
||||
const uint64_t minfreespace_,
|
||||
const char *fusepath_,
|
||||
const int flags_,
|
||||
const bool link_cow_,
|
||||
uint64_t &fh_)
|
||||
{
|
||||
int rv;
|
||||
vector<const string*> basepaths;
|
||||
static
|
||||
int
|
||||
open(Policy::Func::Search searchFunc_,
|
||||
const Branches &branches_,
|
||||
const uint64_t minfreespace_,
|
||||
const char *fusepath_,
|
||||
const int flags_,
|
||||
const bool link_cow_,
|
||||
uint64_t *fh_)
|
||||
{
|
||||
int rv;
|
||||
vector<const string*> basepaths;
|
||||
|
||||
rv = searchFunc_(branches_,fusepath_,minfreespace_,basepaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
rv = searchFunc_(branches_,fusepath_,minfreespace_,basepaths);
|
||||
if(rv == -1)
|
||||
return -errno;
|
||||
|
||||
return _open_core(basepaths[0],fusepath_,flags_,link_cow_,fh_);
|
||||
return local::open_core(*basepaths[0],fusepath_,flags_,link_cow_,fh_);
|
||||
}
|
||||
}
|
||||
|
||||
namespace mergerfs
|
||||
|
|
@ -92,13 +95,14 @@ namespace mergerfs
|
|||
const ugid::Set ugid(fc->uid,fc->gid);
|
||||
const rwlock::ReadGuard readlock(&config.branches_lock);
|
||||
|
||||
return _open(config.open,
|
||||
config.branches,
|
||||
config.minfreespace,
|
||||
fusepath_,
|
||||
ffi_->flags,
|
||||
config.link_cow,
|
||||
ffi_->fh);
|
||||
ffi_->direct_io = config.direct_io;
|
||||
return local::open(config.open,
|
||||
config.branches,
|
||||
config.minfreespace,
|
||||
fusepath_,
|
||||
ffi_->flags,
|
||||
config.link_cow,
|
||||
&ffi_->fh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue