59 return initialStat(sbuff);
62 return m_file->
Fstat(sbuff);
72 int IOFile::initialStat(
struct stat &sbuff)
78 static const char* trace_pfx =
"initialStat ";
88 sbuff.st_size = file_size;
89 TRACE(
Info, trace_pfx <<
"successfully read size " << sbuff.st_size <<
" from info file " << iname);
92 TRACE(
Error, trace_pfx <<
"failed reading from info file " << iname <<
" " <<
XrdSysE2T(-file_size));
96 TRACEIO(
Debug, trace_pfx <<
"stat from client res = " << res <<
", size = " << sbuff.st_size);
127 int pos = 0, cap = 1024;
128 bool truncated =
false;
130 int len = snprintf(&info[pos], cap,
" ( %d : %d)", err, cnt);
139 <<
", block (error : count) report:" << info << (truncated ?
" - truncated" :
""));
157 TRACEIO(Dump,
"Read() sync " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
160 int retval = ReadBegin(buff, off, size, rh);
164 retval = rh->m_retval;
168 return ReadEnd(retval, rh);
178 void Done(
int result)
override {
179 m_io->ReadEnd(result,
this);
188 TRACEIO(Dump,
"Read() async " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
190 int retval = ReadBegin(buff, off, size, rh);
199 std::vector<uint32_t> &csvec, uint64_t
opts,
int *csfix)
204 std::function<void (
int)> m_lambda {0};
206 void Done(
int result)
override {
207 if (m_lambda) m_lambda(result);
208 m_io->ReadEnd(result,
this);
217 TRACEIO(Dump,
"pgRead() async " <<
this <<
" sid: " <<
Xrd::hex1 << rh->m_seq_id <<
" off: " << off <<
" size: " << size);
220 rh->m_lambda = [=, &csvec](
int result) {
225 int retval = ReadBegin(buff, off, size, rh);
233 int IOFile::ReadBegin(
char *buff,
long long off,
int size,
ReadReqRH *rh)
236 if (off >=
FSize()) {
243 if (off + size >
FSize()) {
244 size =
FSize() - off;
248 return m_file->
Read(
this, buff, off, size, rh);
252 int IOFile::ReadEnd(
int retval,
ReadReqRH *rh)
258 }
else if (retval < rh->m_expected_size) {
286 int retval = ReadVBegin(readV, n, rh);
290 retval = rh->m_retval;
293 return ReadVEnd(retval, rh);
303 void Done(
int result)
override { m_io-> ReadVEnd(result,
this); }
313 int retval = ReadVBegin(readV, n, rh);
323 long long file_size =
FSize();
324 for (
int i = 0; i < n; ++i)
336 return m_file->
ReadV(
this, readV, n, rh);
340 int IOFile::ReadVEnd(
int retval,
ReadReqRH *rh)
346 TRACEIO(
Debug,
"ReadVEnd() error in File::ReadV(), exit status=" << retval <<
", error=" <<
XrdSysE2T(-retval));
347 }
else if (retval < rh->m_expected_size) {
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
constexpr int kReadPending
ReadReqRH(unsigned short sid, XrdOucCacheIOCB *iocb)