60 res = initCachedStat();
64 memcpy(&sbuff, m_localStat,
sizeof(
struct stat));
75 int IOFile::initCachedStat()
79 static const char* trace_pfx =
"initCachedStat ";
91 if ((res_open = infoFile->
Open(iname.c_str(), O_RDONLY, 0600, myEnv)) ==
XrdOssOK)
94 if (info.Read(infoFile, iname.c_str()))
97 tmpStat.st_size = info.GetFileSize();
101 if (info.IsComplete())
103 tmpStat.st_mtime = info.GetCreationTime();
104 TRACEIO(
Info, trace_pfx <<
"successfully read size " << tmpStat.st_size <<
" and creation time " << tmpStat.st_mtime <<
" from info file");
108 tmpStat.st_mtime = 0;
109 TRACEIO(
Info, trace_pfx <<
"successfully read size from info file = " << tmpStat.st_size);
116 TRACEIO(
Info, trace_pfx <<
"info file is incomplete or corrupt");
130 TRACEIO(
Debug, trace_pfx <<
"got stat from client res = " << res <<
", size = " << tmpStat.st_size);
134 tmpStat.st_ctime = tmpStat.st_mtime = tmpStat.st_atime = 0;
139 m_localStat =
new struct stat;
140 memcpy(m_localStat, &tmpStat,
sizeof(
struct stat));
164 TRACE(
Info,
"DetachFinalize() " <<
this);
184 TRACEIO(Dump,
"Read() sync " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
187 int retval = ReadBegin(buff, off, size, rh);
188 if (retval == -EWOULDBLOCK)
191 retval = rh->m_retval;
195 return ReadEnd(retval, rh);
205 void Done(
int result)
override {
206 m_io->ReadEnd(result,
this);
215 TRACEIO(Dump,
"Read() async " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
217 int retval = ReadBegin(buff, off, size, rh);
218 if (retval != -EWOULDBLOCK)
226 std::vector<uint32_t> &csvec, uint64_t
opts,
int *csfix)
231 std::function<void (
int)> m_lambda {0};
233 void Done(
int result)
override {
234 if (m_lambda) m_lambda(result);
235 m_io->ReadEnd(result,
this);
244 TRACEIO(Dump,
"pgRead() async " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
247 rh->m_lambda = [=, &csvec](
int result) {
252 int retval = ReadBegin(buff, off, size, rh);
253 if (retval != -EWOULDBLOCK)
260 int IOFile::ReadBegin(
char *buff,
long long off,
int size,
ReadReqRH *rh)
263 if (off >=
FSize()) {
270 if (off + size >
FSize()) {
271 size =
FSize() - off;
275 return m_file->
Read(
this, buff, off, size, rh);
279 int IOFile::ReadEnd(
int retval,
ReadReqRH *rh)
285 }
else if (retval < rh->m_expected_size) {
313 int retval = ReadVBegin(readV, n, rh);
314 if (retval == -EWOULDBLOCK)
317 retval = rh->m_retval;
320 return ReadVEnd(retval, rh);
330 void Done(
int result)
override { m_io-> ReadVEnd(result,
this); }
340 int retval = ReadVBegin(readV, n, rh);
341 if (retval != -EWOULDBLOCK)
350 long long file_size =
FSize();
351 for (
int i = 0; i < n; ++i)
363 return m_file->
ReadV(
this, readV, n, rh);
367 int IOFile::ReadVEnd(
int retval,
ReadReqRH *rh)
373 TRACEIO(
Warning,
"ReadVEnd() error in File::ReadV(), exit status=" << retval <<
", error=" <<
XrdSysE2T(-retval));
374 }
else if (retval < rh->m_expected_size) {
int stat(const char *path, struct stat *buf)
const char * XrdSysE2T(int errcode)
virtual int Close(long long *retsz=0)=0
virtual int Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env)
virtual XrdOssDF * newFile(const char *tident)=0
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0)=0
virtual void Done(int result)=0
virtual int Fstat(struct stat &sbuff)
static const uint64_t forceCS
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
File * GetFile(const std::string &, IO *, long long off=0, long long filesize=0)
static Cache & GetInstance()
Singleton access.
void ReleaseFile(File *, IO *)
int ReadV(IO *io, const XrdOucIOVec *readV, int readVnum, ReadReqRH *rh)
Vector read.
void RequestSyncOfDetachStats()
Flags that detach stats should be written out in final sync. Called from CacheIO upon Detach.
int Read(IO *io, char *buff, long long offset, int size, ReadReqRH *rh)
Normal read.
void ioUpdated(IO *io)
Notification from IO that it has been updated (remote open).
bool ioActive(IO *io)
Initiate close. Return true if still IO active. Used in XrdPosixXrootd::Close()
Downloads original file into a single file on local disk. Handles read requests as they come along.
void Update(XrdOucCacheIO &iocp) override
void DetachFinalize() override
Abstract virtual method of XrdPfc::IO Called to destruct the IO object after it is no longer used.
int Read(char *buff, long long off, int size) override
Pass Read request to the corresponding File object.
int Fstat(struct stat &sbuff) override
bool ioActive() override
Abstract virtual method of XrdPfc::IO Called to check if destruction needs to be done in a separate t...
int ReadV(const XrdOucIOVec *readV, int n) override
Pass ReadV request to the corresponding File object.
long long FSize() override
IOFile(XrdOucCacheIO *io, Cache &cache)
virtual int pgRead(char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
Base cache-io class that implements some XrdOucCacheIO abstract methods.
std::string GetFilename()
XrdOucCacheIO * GetInput()
Cache & m_cache
reference to Cache object
RAtomic_int m_active_read_reqs
number of active read requests
const char * RefreshLocation()
void Update(XrdOucCacheIO &iocp) override
unsigned short ObtainReadSid()
Status of cached file. Can be read from and written into a binary file.
static const char * s_infoExtension
ReadReqRH(unsigned short sid, XrdOucCacheIOCB *iocb)