59 return initialStat(sbuff);
62 return m_file->
Fstat(sbuff);
72 int IOFile::initialStat(
struct stat &sbuff)
78 static const char* trace_pfx =
"initialStat ";
86 sbuff.st_size = file_size;
87 TRACEIO(
Info, trace_pfx <<
"successfully read size " << sbuff.st_size <<
" from info file");
94 TRACEIO(
Debug, trace_pfx <<
"stat from client res = " << res <<
", size = " << sbuff.st_size);
125 int pos = 0, cap = 1024;
126 bool truncated =
false;
128 int len = snprintf(&info[pos], cap,
" ( %d : %d)", err, cnt);
137 <<
", block (error : count) report:" << info << (truncated ?
" - truncated" :
""));
155 TRACEIO(Dump,
"Read() sync " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
158 int retval = ReadBegin(buff, off, size, rh);
159 if (retval == -EWOULDBLOCK)
162 retval = rh->m_retval;
166 return ReadEnd(retval, rh);
176 void Done(
int result)
override {
177 m_io->ReadEnd(result,
this);
186 TRACEIO(Dump,
"Read() async " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
188 int retval = ReadBegin(buff, off, size, rh);
189 if (retval != -EWOULDBLOCK)
197 std::vector<uint32_t> &csvec, uint64_t
opts,
int *csfix)
202 std::function<void (
int)> m_lambda {0};
204 void Done(
int result)
override {
205 if (m_lambda) m_lambda(result);
206 m_io->ReadEnd(result,
this);
215 TRACEIO(Dump,
"pgRead() async " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
218 rh->m_lambda = [=, &csvec](
int result) {
223 int retval = ReadBegin(buff, off, size, rh);
224 if (retval != -EWOULDBLOCK)
231 int IOFile::ReadBegin(
char *buff,
long long off,
int size,
ReadReqRH *rh)
234 if (off >=
FSize()) {
241 if (off + size >
FSize()) {
242 size =
FSize() - off;
246 return m_file->
Read(
this, buff, off, size, rh);
250 int IOFile::ReadEnd(
int retval,
ReadReqRH *rh)
256 }
else if (retval < rh->m_expected_size) {
284 int retval = ReadVBegin(readV, n, rh);
285 if (retval == -EWOULDBLOCK)
288 retval = rh->m_retval;
291 return ReadVEnd(retval, rh);
301 void Done(
int result)
override { m_io-> ReadVEnd(result,
this); }
311 int retval = ReadVBegin(readV, n, rh);
312 if (retval != -EWOULDBLOCK)
321 long long file_size =
FSize();
322 for (
int i = 0; i < n; ++i)
334 return m_file->
ReadV(
this, readV, n, rh);
338 int IOFile::ReadVEnd(
int retval,
ReadReqRH *rh)
344 TRACEIO(
Debug,
"ReadVEnd() error in File::ReadV(), exit status=" << retval <<
", error=" <<
XrdSysE2T(-retval));
345 }
else if (retval < rh->m_expected_size) {
int stat(const char *path, struct stat *buf)
const char * XrdSysE2T(int errcode)
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.
long long DetermineFullFileSize(const std::string &cinfo_fname)
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.
int Fstat(struct stat &sbuff)
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).
long long GetFileSize() const
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::map< int, int > m_error_counts
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()
std::string GetFilename()
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)