XRootD
XrdOucCacheIO Class Referenceabstract

#include <XrdOucCache.hh>

+ Inheritance diagram for XrdOucCacheIO:
+ Collaboration diagram for XrdOucCacheIO:

Classes

struct  aprParms
 

Public Member Functions

 XrdOucCacheIO ()
 Construct and Destructor. More...
 
virtual bool Detach (XrdOucCacheIOCD &iocd)=0
 
virtual long long FSize ()=0
 
virtual int Fstat (struct stat &sbuff)
 
virtual const char * Location (bool refresh=false)
 
virtual const char * Path ()=0
 
virtual int pgRead (char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
 
virtual void pgRead (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
 
virtual int pgWrite (char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
 
virtual void pgWrite (XrdOucCacheIOCB &iocb, char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
 
virtual void Preread (aprParms &Parms)
 
virtual void Preread (long long offs, int rlen, int opts=0)
 
virtual int Read (char *buff, long long offs, int rlen)=0
 
virtual void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
 
virtual int ReadV (const XrdOucIOVec *readV, int rnum)
 
virtual void ReadV (XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
 
virtual int Sync ()=0
 
virtual void Sync (XrdOucCacheIOCB &iocb)
 
virtual int Trunc (long long offs)=0
 
virtual void Trunc (XrdOucCacheIOCB &iocb, long long offs)
 
virtual void Update (XrdOucCacheIO &iocp)
 
virtual int Write (char *buff, long long offs, int wlen)=0
 
virtual void Write (XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
 
virtual int WriteV (const XrdOucIOVec *writV, int wnum)
 
virtual void WriteV (XrdOucCacheIOCB &iocb, const XrdOucIOVec *writV, int wnum)
 

Static Public Attributes

static const uint64_t forceCS = 0x0000000000000001ULL
 
static const int SingleUse = 0x0001
 Mark pages for single use. More...
 

Protected Member Functions

virtual ~XrdOucCacheIO ()
 

Detailed Description

The XrdOucCacheIO object is responsible for interacting with the original data source/target. It can be used with or without a front-end cache.

Definition at line 104 of file XrdOucCache.hh.

Constructor & Destructor Documentation

◆ XrdOucCacheIO()

XrdOucCacheIO::XrdOucCacheIO ( )
inline

Construct and Destructor.

Definition at line 480 of file XrdOucCache.hh.

480 {}

◆ ~XrdOucCacheIO()

virtual XrdOucCacheIO::~XrdOucCacheIO ( )
inlineprotectedvirtual

Definition at line 482 of file XrdOucCache.hh.

482 {} // Always use Detach() instead of direct delete!

Member Function Documentation

◆ Detach()

virtual bool XrdOucCacheIO::Detach ( XrdOucCacheIOCD iocd)
pure virtual

Detach this CacheIO object from the cache.

Note
This method must be called instead of using the delete operator since CacheIO objects may have multiple outstanding references and actual deletion may need to be deferred.
Parameters
iocdreference to the detach complete callback object.
Returns
true Deletion can occur immediately. There is no outstanding I/O.
false Deletion must be deferred until it is safe to so from the cache perspective. At which point, the cache will call the DetachDone() method in the passed callback object. No locks may be held with respect to the CacheIO object when this is done to avoid deadlocks.

Implemented in XrdPfc::IO, XrdRmcData, XrdPosixFile, and XrdPosixPrepIO.

Referenced by XrdPosixXrootd::Close().

+ Here is the caller graph for this function:

◆ FSize()

virtual long long XrdOucCacheIO::FSize ( )
pure virtual

Obtain size of the file.

Returns
Size of the file in bytes.

Implemented in XrdPosixFile, XrdPfc::IOFileBlock, XrdPfc::IOFile, XrdRmcData, and XrdPosixPrepIO.

Referenced by XrdRmcData::FSize(), XrdPosixFile::Fstat(), and XrdPosixXrootd::Lseek().

+ Here is the caller graph for this function:

◆ Fstat()

virtual int XrdOucCacheIO::Fstat ( struct stat sbuff)
inlinevirtual

Perform an fstat() operation (defaults to passthrough).

Parameters
sbuffreference to the stat buffer to be filled in. Only fields st_size, st_blocks, st_mtime (st_atime and st_ctime may be set to st_mtime), st_ino, and st_mode need to be set. All other fields are preset and should not be changed.
Returns
<0 - fstat failed, value is -errno. =0 - fstat succeeded, sbuff holds stat information. >0 - fstat could not be done, forward operation to next level.

Reimplemented in XrdPfc::IOFileBlock, XrdPfc::IOFile, XrdPosixFile, and XrdPosixPrepIO.

Definition at line 148 of file XrdOucCache.hh.

148 {(void)sbuff; return 1;}

Referenced by XrdPosixXrootd::Fstat(), and XrdPfc::Cache::GetFile().

+ Here is the caller graph for this function:

◆ Location()

virtual const char* XrdOucCacheIO::Location ( bool  refresh = false)
inlinevirtual

Get the file's location (i.e. endpoint hostname and port)

Parameters
refresh- when true, recomputes the location in case it changed st the location is cached from the previous successful call.
Returns
A pointer to the file's location. It remains valid until the file is closed or Location() is called with refresh set to true. A null string means the file is not open or location is unknown.

Reimplemented in XrdPosixFile.

Definition at line 161 of file XrdOucCache.hh.

161 {(void)refresh; return "";}

Referenced by XrdPfc::Cache::Attach().

+ Here is the caller graph for this function:

◆ Path()

virtual const char* XrdOucCacheIO::Path ( )
pure virtual

Get the path associated with this object.

Returns
Pointer to the path.

Implemented in XrdPosixFile, XrdPfc::IO, XrdRmcData, and XrdPosixPrepIO.

Referenced by XrdPfc::Cache::Attach(), XrdRmcReal::Attach(), XrdPfc::Cache::Decide(), XrdRmcData::Detach(), XrdRmcData::Path(), and XrdRmcData::Preread().

+ Here is the caller graph for this function:

◆ pgRead() [1/2]

int XrdOucCacheIO::pgRead ( char *  buff,
long long  offs,
int  rdlen,
std::vector< uint32_t > &  csvec,
uint64_t  opts = 0,
int *  csfix = 0 
)
virtual

Reimplemented in XrdPosixFile.

Definition at line 39 of file XrdOucCache.cc.

45 {
46  (void)csfix;
47  int bytes;
48 
49 // Read the data into the buffer
50 //
51  bytes = Read(buff, offs, rdlen);
52 
53 // Calculate checksums if so wanted
54 //
55  if (bytes > 0 && (opts & forceCS))
56  XrdOucPgrwUtils::csCalc((const char *)buff, (ssize_t)offs,
57  (size_t)bytes, csvec);
58 
59 // All done
60 //
61  return bytes;
62 }
struct myOpts opts
virtual int Read(char *buff, long long offs, int rlen)=0
static const uint64_t forceCS
Definition: XrdOucCache.hh:188
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)

References XrdOucPgrwUtils::csCalc(), forceCS, opts, and Read().

Referenced by XrdPosixExtra::pgRead(), and pgRead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgRead() [2/2]

virtual void XrdOucCacheIO::pgRead ( XrdOucCacheIOCB iocb,
char *  buff,
long long  offs,
int  rdlen,
std::vector< uint32_t > &  csvec,
uint64_t  opts = 0,
int *  csfix = 0 
)
inlinevirtual

Read file pages and checksums using asynchronous I/O (default sync).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
buffpointer to buffer where the bytes are to be placed.
offsThe offset where the read is to start.
rdlenThe number of bytes to read.
csvecA vector which will be filled with the corresponding CRC32C checksum for each page or page segment.
optsProcessing options: forceCS - always return checksums even when not available.
csfixWhen not nil, returns the number of corrected checksum errs.

Reimplemented in XrdPosixFile, and XrdPfc::IOFile.

Definition at line 214 of file XrdOucCache.hh.

221  {iocb.Done(pgRead(buff, offs, rdlen, csvec, opts, csfix));}
virtual void Done(int result)=0
virtual int pgRead(char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
Definition: XrdOucCache.cc:39

References XrdOucCacheIOCB::Done(), opts, and pgRead().

+ Here is the call graph for this function:

◆ pgWrite() [1/2]

int XrdOucCacheIO::pgWrite ( char *  buff,
long long  offs,
int  wrlen,
std::vector< uint32_t > &  csvec,
uint64_t  opts = 0,
int *  csfix = 0 
)
virtual

Write file pages from a buffer and corresponding verified checksums.

Parameters
buffpointer to buffer holding the bytes to be written.
offsThe offset where the write is to start.
wrlenThe number of bytes to write. offs+wrlen (i.e. it establishes an end of file).
csvecA vector of that holds the corresponding verified CRC32C checksum for each page or page segment.
optsProcessing options.
csfixWhen not nil, returns the number of corrected checksum errs.
Returns
>= 0 The number of bytes written.
-errno File could not be written, returned value is the reason.

Reimplemented in XrdPosixFile.

Definition at line 68 of file XrdOucCache.cc.

74 {
75  (void)csvec; (void)opts; (void)csfix;
76 
77 // Now just return the result of a plain write
78 //
79  return Write(buff, offs, wrlen);
80 }
virtual int Write(char *buff, long long offs, int wlen)=0

References opts, and Write().

Referenced by XrdPosixExtra::pgWrite(), and pgWrite().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgWrite() [2/2]

virtual void XrdOucCacheIO::pgWrite ( XrdOucCacheIOCB iocb,
char *  buff,
long long  offs,
int  wrlen,
std::vector< uint32_t > &  csvec,
uint64_t  opts = 0,
int *  csfix = 0 
)
inlinevirtual

Write file pages and checksums using asynchronous I/O (default sync).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
buffpointer to buffer holding the bytes to be written.
offsThe offset where the write is to start.
wrlenThe number of bytes to write.
csvecA vector of that holds the corresponding verified CRC32C checksum for each page or page segment.
optsProcessing options.
csfixWhen not nil, returns the number of corrected checksum errs.

Reimplemented in XrdPosixFile.

Definition at line 262 of file XrdOucCache.hh.

269  {iocb.Done(pgWrite(buff, offs, wrlen, csvec, opts, csfix));}
virtual int pgWrite(char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
Definition: XrdOucCache.cc:68

References XrdOucCacheIOCB::Done(), opts, and pgWrite().

+ Here is the call graph for this function:

◆ Preread() [1/2]

virtual void XrdOucCacheIO::Preread ( aprParms Parms)
inlinevirtual

Reimplemented in XrdRmcData.

Definition at line 304 of file XrdOucCache.hh.

304 { (void)Parms; }

◆ Preread() [2/2]

virtual void XrdOucCacheIO::Preread ( long long  offs,
int  rlen,
int  opts = 0 
)
inlinevirtual

Reimplemented in XrdRmcData.

Definition at line 281 of file XrdOucCache.hh.

282  {(void)offs; (void)rlen; (void)opts;}

References opts.

◆ Read() [1/2]

virtual int XrdOucCacheIO::Read ( char *  buff,
long long  offs,
int  rlen 
)
pure virtual

Perform an synchronous read.

Parameters
buffpointer to the buffer to receive the results. The buffer must remain valid until the callback is invoked.
offsthe offset into the file.
rlenthe number of bytes to read.
Returns
< 0 - Read failed, value is -errno. >=0 - Read succeeded, value is number of bytes read.

Implemented in XrdPfc::IOFileBlock, XrdRmcData, XrdPosixPrepIO, XrdPosixFile, and XrdPfc::IOFile.

Referenced by pgRead(), XrdPosixXrootd::Pread(), XrdPfc::IOFileBlock::Read(), XrdPosixXrootd::Read(), Read(), and ReadV().

+ Here is the caller graph for this function:

◆ Read() [2/2]

virtual void XrdOucCacheIO::Read ( XrdOucCacheIOCB iocb,
char *  buff,
long long  offs,
int  rlen 
)
inlinevirtual

Perform an asynchronous read (defaults to synchronous).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
buffpointer to the buffer to receive the results. The buffer must remain valid until the callback is invoked.
offsthe offset into the file.
rlenthe number of bytes to read.

Reimplemented in XrdPosixFile, XrdPosixPrepIO, and XrdPfc::IOFile.

Definition at line 333 of file XrdOucCache.hh.

334  {iocb.Done(Read(buff, offs, rlen));}

References XrdOucCacheIOCB::Done(), and Read().

+ Here is the call graph for this function:

◆ ReadV() [1/2]

int XrdOucCacheIO::ReadV ( const XrdOucIOVec readV,
int  rnum 
)
virtual

Perform an synchronous vector read.

Parameters
readVpointer to a vector of read requests.
rnumthe number of elements in the vector.
Returns
< 0 - ReadV failed, value is -errno. >=0 - ReadV succeeded, value is number of bytes read.

Reimplemented in XrdPosixFile, XrdPfc::IOFile, and XrdPosixPrepIO.

Definition at line 86 of file XrdOucCache.cc.

87 {
88  int nbytes = 0, curCount = 0;
89 
90  for (int i = 0; i < rnum; i++)
91  {curCount = Read(readV[i].data, readV[i].offset, readV[i].size);
92  if (curCount != readV[i].size)
93  return (curCount < 0 ? curCount : -ESPIPE);
94  nbytes += curCount;
95  }
96  return nbytes;
97 }

References Read().

Referenced by ReadV(), and XrdPosixXrootd::VRead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadV() [2/2]

virtual void XrdOucCacheIO::ReadV ( XrdOucCacheIOCB iocb,
const XrdOucIOVec readV,
int  rnum 
)
inlinevirtual

Perform an asynchronous vector read (defaults to synchronous).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
readVpointer to a vector of read requests.
rnumthe number of elements in the vector.

Reimplemented in XrdPosixPrepIO, XrdPosixFile, and XrdPfc::IOFile.

Definition at line 359 of file XrdOucCache.hh.

360  {iocb.Done(ReadV(readV, rnum));}
virtual int ReadV(const XrdOucIOVec *readV, int rnum)
Definition: XrdOucCache.cc:86

References XrdOucCacheIOCB::Done(), and ReadV().

+ Here is the call graph for this function:

◆ Sync() [1/2]

virtual int XrdOucCacheIO::Sync ( )
pure virtual

Perform an synchronous sync() operation.

Returns
<0 - Sync failed, value is -errno. =0 - Sync succeeded.

Implemented in XrdPfc::IO, XrdPfc::IO, XrdPosixFile, XrdPfc::IO, XrdRmcData, and XrdPosixPrepIO.

Referenced by XrdPosixXrootd::Fsync().

+ Here is the caller graph for this function:

◆ Sync() [2/2]

virtual void XrdOucCacheIO::Sync ( XrdOucCacheIOCB iocb)
inlinevirtual

Perform an asynchronous sync() operation (defaults to synchronous).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.

Reimplemented in XrdPosixFile, and XrdPosixPrepIO.

Definition at line 380 of file XrdOucCache.hh.

380 {iocb.Done(Sync());}
virtual int Sync()=0

References XrdOucCacheIOCB::Done(), and Sync().

Referenced by Sync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Trunc() [1/2]

virtual int XrdOucCacheIO::Trunc ( long long  offs)
pure virtual

Perform an synchronous trunc() operation.

Parameters
offsthe size the file is have.
Returns
<0 - Trunc failed, value is -errno. =0 - Trunc succeeded.

Implemented in XrdPosixFile, XrdPfc::IO, XrdRmcData, and XrdPosixPrepIO.

Referenced by XrdPosixXrootd::Ftruncate(), XrdRmcData::Trunc(), and Trunc().

+ Here is the caller graph for this function:

◆ Trunc() [2/2]

virtual void XrdOucCacheIO::Trunc ( XrdOucCacheIOCB iocb,
long long  offs 
)
inlinevirtual

Perform an asynchronous trunc() operation (defaults to synchronous).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
offsthe size the file is have.

Definition at line 403 of file XrdOucCache.hh.

404  {iocb.Done(Trunc(offs));}
virtual int Trunc(long long offs)=0

References XrdOucCacheIOCB::Done(), and Trunc().

+ Here is the call graph for this function:

◆ Update()

virtual void XrdOucCacheIO::Update ( XrdOucCacheIO iocp)
inlinevirtual

Update the originally passed XrdOucCacheIO object with the object passed. All future uses underlying XrdOucCacheIO object must now use this object. Update() is called when Prepare() indicated that the file should not be physically opened and a file method was invoked in the XrdOucCacheIO passed to Attach(). When this occurs, the file is actually opened and Update() called to replace the original XrdOucCacheIO object with one that uses the newly opened file.

Parameters
iocpreference to the new XrdOucCacheIO object.

Reimplemented in XrdPfc::IOFileBlock, XrdPfc::IOFile, and XrdPfc::IO.

Definition at line 418 of file XrdOucCache.hh.

418 {}

◆ Write() [1/2]

virtual int XrdOucCacheIO::Write ( char *  buff,
long long  offs,
int  wlen 
)
pure virtual

Perform an synchronous write.

Parameters
buffpointer to the buffer holding the contents. The buffer must remain valid until the callback is invoked.
offsthe offset into the file.
wlenthe number of bytes to write
Returns
< 0 - Write failed, value is -errno. >=0 - Write succeeded, value is number of bytes written.

Implemented in XrdPfc::IO, XrdRmcData, XrdPosixPrepIO, and XrdPosixFile.

Referenced by pgWrite(), XrdPosixXrootd::Pwrite(), XrdRmcData::Write(), XrdPosixXrootd::Write(), Write(), and WriteV().

+ Here is the caller graph for this function:

◆ Write() [2/2]

virtual void XrdOucCacheIO::Write ( XrdOucCacheIOCB iocb,
char *  buff,
long long  offs,
int  wlen 
)
inlinevirtual

Perform an asynchronous write (defaults to synchronous).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
buffpointer to the buffer holding the contents. The buffer must remain valid until the callback is invoked.
offsthe offset into the file.
wlenthe number of bytes to write

Reimplemented in XrdPosixFile, and XrdPosixPrepIO.

Definition at line 447 of file XrdOucCache.hh.

448  {iocb.Done(Write(buff, offs, wlen));}

References XrdOucCacheIOCB::Done(), and Write().

+ Here is the call graph for this function:

◆ WriteV() [1/2]

int XrdOucCacheIO::WriteV ( const XrdOucIOVec writV,
int  wnum 
)
virtual

Perform an synchronous vector write.

Parameters
writVpointer to a vector of write requests.
wnumthe number of elements in the vector.
Returns
< 0 - WriteV failed, value is -errno. >=0 - WriteV succeeded, value is number of bytes written.

Definition at line 103 of file XrdOucCache.cc.

104 {
105  int nbytes = 0, curCount = 0;
106 
107  for (int i = 0; i < wnum; i++)
108  {curCount = Write(writV[i].data, writV[i].offset, writV[i].size);
109  if (curCount != writV[i].size)
110  {if (curCount < 0) return curCount;
111  return -ESPIPE;
112  }
113  nbytes += curCount;
114  }
115  return nbytes;
116 }

References Write().

Referenced by WriteV().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteV() [2/2]

virtual void XrdOucCacheIO::WriteV ( XrdOucCacheIOCB iocb,
const XrdOucIOVec writV,
int  wnum 
)
inlinevirtual

Perform an asynchronous vector write (defaults to synchronous).

Parameters
iocbreference to the callback object that receives the result. All results are returned via this object's Done() method. If the caller holds any locks they must be recursive locks as the callback may occur on the calling thread.
writVpointer to a vector of read requests.
wnumthe number of elements in the vector.

Definition at line 473 of file XrdOucCache.hh.

474  {iocb.Done(WriteV(writV, wnum));}
virtual int WriteV(const XrdOucIOVec *writV, int wnum)
Definition: XrdOucCache.cc:103

References XrdOucCacheIOCB::Done(), and WriteV().

+ Here is the call graph for this function:

Member Data Documentation

◆ forceCS

const uint64_t XrdOucCacheIO::forceCS = 0x0000000000000001ULL
static

Read file pages into a buffer and return corresponding checksums.

Parameters
buffpointer to buffer where the bytes are to be placed.
offsThe offset where the read is to start.
rdlenThe number of bytes to read.
csvecA vector whose entries which will be filled with the corresponding CRC32C checksum for each page or pgae segment. If a zero length vector is returned, checksums are not present.
optsProcessing options: forceCS - always return checksums even when not available.
csfixWhen not nil, returns the number of corrected checksum errs.
Returns
>= 0 The number of bytes placed in buffer.
-errno File could not be read, return value is the reason.

Definition at line 188 of file XrdOucCache.hh.

Referenced by pgRead(), XrdPosixExtra::pgRead(), XrdPfc::IOFile::pgRead(), and XrdPosixFile::pgRead().

◆ SingleUse

const int XrdOucCacheIO::SingleUse = 0x0001
static

Mark pages for single use.

Perform an asynchronous preread (may be ignored).

Parameters
offsthe offset into the file.
rlenthe number of bytes to preread into the cache.
optsone or more of the options defined below.

Definition at line 279 of file XrdOucCache.hh.

Referenced by XrdRmcData::Preread().


The documentation for this class was generated from the following files: