mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-19 16:16:48 +00:00
Use nanosleep rather than yield and return EINTR
This commit is contained in:
committed by
trapexit
parent
3905355522
commit
425e30b50f
+5
-6
@@ -114,11 +114,10 @@ _calculate_flush(FlushOnClose const flushonclose_,
|
||||
|
||||
static
|
||||
void
|
||||
_config_to_ffi_flags(Config &cfg_,
|
||||
const int tid_,
|
||||
_config_to_ffi_flags(const int tid_,
|
||||
fuse_file_info_t *ffi_)
|
||||
{
|
||||
switch(cfg_.cache_files)
|
||||
switch(cfg.cache_files)
|
||||
{
|
||||
case CacheFiles::ENUM::OFF:
|
||||
ffi_->direct_io = 1;
|
||||
@@ -144,7 +143,7 @@ _config_to_ffi_flags(Config &cfg_,
|
||||
std::string proc_name;
|
||||
|
||||
proc_name = procfs::get_name(tid_);
|
||||
if(cfg_.cache_files_process_names.count(proc_name) == 0)
|
||||
if(cfg.cache_files_process_names.count(proc_name) == 0)
|
||||
{
|
||||
ffi_->direct_io = 1;
|
||||
ffi_->keep_cache = 0;
|
||||
@@ -159,7 +158,7 @@ _config_to_ffi_flags(Config &cfg_,
|
||||
break;
|
||||
}
|
||||
|
||||
if(cfg_.parallel_direct_writes == true)
|
||||
if(cfg.parallel_direct_writes == true)
|
||||
ffi_->parallel_direct_writes = ffi_->direct_io;
|
||||
}
|
||||
|
||||
@@ -261,7 +260,7 @@ _create(const fuse_req_ctx_t *ctx_,
|
||||
{
|
||||
auto &of = state.open_files;
|
||||
|
||||
::_config_to_ffi_flags(cfg,ctx_->pid,ffi_);
|
||||
::_config_to_ffi_flags(ctx_->pid,ffi_);
|
||||
if(cfg.cache_writeback)
|
||||
::_tweak_flags_cache_writeback(&ffi_->flags);
|
||||
ffi_->noflush = !::_calculate_flush(cfg.flushonclose,ffi_->flags);
|
||||
|
||||
+12
-6
@@ -212,8 +212,7 @@ _calculate_flush(FlushOnClose const flushonclose_,
|
||||
|
||||
static
|
||||
void
|
||||
_config_to_ffi_flags(Config &cfg_,
|
||||
const int tid_,
|
||||
_config_to_ffi_flags(const int tid_,
|
||||
fuse_file_info_t *ffi_)
|
||||
{
|
||||
switch(cfg.cache_files)
|
||||
@@ -354,12 +353,12 @@ _open(const fuse_req_ctx_t *ctx_,
|
||||
int rv;
|
||||
auto &of = state.open_files;
|
||||
|
||||
::_config_to_ffi_flags(cfg,ctx_->pid,ffi_);
|
||||
::_config_to_ffi_flags(ctx_->pid,ffi_);
|
||||
if(cfg.cache_writeback)
|
||||
::_tweak_flags_cache_writeback(&ffi_->flags);
|
||||
ffi_->noflush = !::_calculate_flush(cfg.flushonclose,ffi_->flags);
|
||||
|
||||
for(size_t i = 0; i < MAX_OPEN_RETRIES; i++)
|
||||
for(int i = 0; i < MAX_OPEN_RETRIES; i++)
|
||||
{
|
||||
FileInfo *fi = nullptr;
|
||||
int backing_id = INVALID_BACKING_ID;
|
||||
@@ -456,10 +455,17 @@ _open(const fuse_req_ctx_t *ctx_,
|
||||
fs::close(fi->fd);
|
||||
delete fi;
|
||||
ffi_->fh = 0;
|
||||
::sched_yield();
|
||||
|
||||
struct timespec duration = {0,((i+1)*1000)};
|
||||
::nanosleep(&duration,NULL);
|
||||
}
|
||||
|
||||
return -EAGAIN;
|
||||
// Perhaps not the best error to return but it is EXTREMELY unlikely
|
||||
// to be hit and if so the system is probably under a lot of
|
||||
// stress. Give the app the opportunity to try it again. If it can't
|
||||
// it'll error probably similarly as having had returned EIO or
|
||||
// similar.
|
||||
return -EINTR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user