diff --git a/src/fuse_create.cpp b/src/fuse_create.cpp index 8a847d7b..a05e6210 100644 --- a/src/fuse_create.cpp +++ b/src/fuse_create.cpp @@ -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); diff --git a/src/fuse_open.cpp b/src/fuse_open.cpp index 4b99fb8e..251decab 100644 --- a/src/fuse_open.cpp +++ b/src/fuse_open.cpp @@ -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; }