5#include "XrdVersion.hh"
36 const std::lock_guard lock(mutex);
43 if (is_entry_being_written(path))
48 entries.try_emplace(path, std::make_shared<XrdOssMirageEntry>());
49 entries[path]->size = 0;
51 static std::once_flag xattr_injection_flag;
52 std::call_once(xattr_injection_flag, [
this]()
noexcept
83 const std::lock_guard lock(mutex);
85 if (!has_entry(oPath))
91 entries[nPath] = std::move(entries[oPath]);
99 const std::lock_guard lock(mutex);
101 if (!has_entry(path))
105 buff->st_size = entries[path]->size;
112 const std::lock_guard lock(mutex);
114 if (!has_entry(path))
117 if (is_entry_being_written(path))
120 entries[path]->size = fsize;
127 const std::lock_guard lock(mutex);
129 if (!has_entry(path))
139 const std::lock_guard lock(mutex);
141 if (!has_entry(path) || is_entry_being_written(path))
144 return *entries[path];
149 const std::lock_guard lock(mutex);
151 if (!has_entry(path) || is_entry_being_written(path))
154 return entries[path];
157bool XrdOssMirage::has_entry(
const char *path)
159 return entries.find(path) != entries.end();
162bool XrdOssMirage::is_entry_being_written(
const char *path)
164 return entries[path].use_count() > 1;
XrdOss * XrdOssGetStorageSystem(XrdOss *native_oss, XrdSysLogger *lp, const char *config_fn, const char *parms)
XrdVERSIONINFO(XrdOssGetStorageSystem, XrdOssMirage)
XrdOss * XrdOssGetStorageSystem(XrdOss *native_oss, XrdSysLogger *lp, const char *config_fn, const char *parms)
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0) override
virtual int Init(XrdSysLogger *lp, const char *cfn) override
virtual XrdOssDF * newDir(const char *tident) override
virtual int Chmod(const char *path, mode_t mode, XrdOucEnv *envP=0) override
std::optional< XrdOssMirageEntry > get_entry_read(const char *path)
virtual int Create(const char *tid, const char *path, mode_t mode, XrdOucEnv &env, int opts=0) override
virtual int Mkdir(const char *path, mode_t mode, int mkpath=0, XrdOucEnv *envP=0) override
virtual int Rename(const char *oPath, const char *nPath, XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0) override
virtual int Truncate(const char *path, unsigned long long fsize, XrdOucEnv *envP=0) override
std::optional< XrdOssMirageEntryPtr > get_entry_write(const char *path)
virtual XrdOssDF * newFile(const char *tident) override
virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0) override
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0) override
virtual uint64_t Features() override