XRootD
XrdPfc::IO Class Referenceabstract

Base cache-io class that implements some XrdOucCacheIO abstract methods. More...

#include <XrdPfcIO.hh>

+ Inheritance diagram for XrdPfc::IO:
+ Collaboration diagram for XrdPfc::IO:

Classes

struct  ReadReqRHCond
 

Public Member Functions

 IO (XrdOucCacheIO *io, Cache &cache)
 
virtual XrdOucCacheIOBase ()
 Original data source. More...
 
bool Detach (XrdOucCacheIOCD &iocdP) final
 
virtual void DetachFinalize ()=0
 
XrdOucCacheIOGetInput ()
 
const char * GetLocation ()
 
XrdSysTraceGetTrace ()
 
virtual bool ioActive ()=0
 
const char * Path () override
 Original data source URL. More...
 
int Sync () override
 
virtual int Sync ()=0
 
virtual void Sync (XrdOucCacheIOCB &iocb)
 
virtual int Trunc (long long offs)=0
 
int Trunc (long long Offset) override
 
virtual void Trunc (XrdOucCacheIOCB &iocb, long long offs)
 
void Update (XrdOucCacheIO &iocp) override
 
virtual int Write (char *buff, long long offs, int wlen)=0
 
int Write (char *Buffer, long long Offset, int Length) override
 
virtual void Write (XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
 
- Public Member Functions inherited from XrdOucCacheIO
 XrdOucCacheIO ()
 Construct and Destructor. More...
 
virtual long long FSize ()=0
 
virtual int Fstat (struct stat &sbuff)
 
virtual const char * Location (bool refresh=false)
 
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 void Sync (XrdOucCacheIOCB &iocb)
 
virtual void Trunc (XrdOucCacheIOCB &iocb, long long offs)
 
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)
 

Protected Member Functions

std::string GetFilename ()
 
const char * GetPath ()
 
unsigned short ObtainReadSid ()
 
const char * RefreshLocation ()
 
bool register_block_error (int res)
 
bool register_incomplete_read ()
 
- Protected Member Functions inherited from XrdOucCacheIO
virtual ~XrdOucCacheIO ()
 

Protected Attributes

RAtomic_int m_active_read_reqs
 number of active read requests More...
 
Cachem_cache
 reference to Cache object More...
 
std::map< int, int > m_error_counts
 
int m_incomplete_count {0}
 
const char * m_traceID
 

Friends

class File
 

Additional Inherited Members

- Static Public Attributes inherited from XrdOucCacheIO
static const uint64_t forceCS = 0x0000000000000001ULL
 
static const int SingleUse = 0x0001
 Mark pages for single use. More...
 

Detailed Description

Base cache-io class that implements some XrdOucCacheIO abstract methods.

Definition at line 15 of file XrdPfcIO.hh.

Constructor & Destructor Documentation

◆ IO()

IO::IO ( XrdOucCacheIO io,
Cache cache 
)

Definition at line 7 of file XrdPfcIO.cc.

7  :
8  m_cache (cache),
9  m_traceID ("IO"),
11  m_io (io),
12  m_read_seqid (0u)
13 {}
const char * m_traceID
Definition: XrdPfcIO.hh:51
Cache & m_cache
reference to Cache object
Definition: XrdPfcIO.hh:50
RAtomic_int m_active_read_reqs
number of active read requests
Definition: XrdPfcIO.hh:70

Member Function Documentation

◆ Base()

virtual XrdOucCacheIO* XrdPfc::IO::Base ( )
inlinevirtual

Original data source.

Definition at line 21 of file XrdPfcIO.hh.

21 { return m_io; }

◆ Detach()

bool IO::Detach ( XrdOucCacheIOCD iocd)
finalvirtual

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.

Implements XrdOucCacheIO.

Definition at line 43 of file XrdPfcIO.cc.

44 {
45  // Called from XrdPosixFile when local connection is closed.
46 
47  if ( ! ioActive())
48  {
50 
51  return true;
52  }
53  else
54  {
55  class FutureDetach : public XrdJob
56  {
57  IO *f_io;
58  XrdOucCacheIOCD *f_detach_cb;
59  time_t f_wait_time;
60 
61  public:
62  FutureDetach(IO *io, XrdOucCacheIOCD *cb, time_t wt) :
63  f_io (io),
64  f_detach_cb (cb),
65  f_wait_time (wt)
66  {}
67 
68  void DoIt()
69  {
70  if (f_io->ioActive())
71  {
72  // Reschedule up to 120 sec in the future.
73  f_wait_time = std::min(2 * f_wait_time, (time_t) 120);
74  Schedule();
75  }
76  else
77  {
78  f_io->DetachFinalize();
79  f_detach_cb->DetachDone();
80 
81  delete this;
82  }
83  }
84 
85  void Schedule()
86  {
87  Cache::schedP->Schedule(this, time(0) + f_wait_time);
88  }
89  };
90 
91  (new FutureDetach(this, &iocdP, 10))->Schedule();
92 
93  return false;
94  }
95 }
int DoIt(int argpnt, int argc, char **argv, bool singleshot)
Definition: XrdAccTest.cc:262
Definition: XrdJob.hh:43
virtual void DetachDone()=0
Indicate that the CacheIO object has been detached.
static XrdScheduler * schedP
Definition: XrdPfc.hh:290
Base cache-io class that implements some XrdOucCacheIO abstract methods.
Definition: XrdPfcIO.hh:16
virtual bool ioActive()=0
virtual void DetachFinalize()=0
void Schedule(XrdJob *jp)

References XrdOucCacheIOCD::DetachDone(), DetachFinalize(), DoIt(), ioActive(), XrdPfc::Cache::schedP, and XrdScheduler::Schedule().

+ Here is the call graph for this function:

◆ DetachFinalize()

virtual void XrdPfc::IO::DetachFinalize ( )
pure virtual

Implemented in XrdPfc::IOFileBlock, and XrdPfc::IOFile.

Referenced by Detach().

+ Here is the caller graph for this function:

◆ GetFilename()

std::string IO::GetFilename ( )
protected

Definition at line 36 of file XrdPfcIO.cc.

37 {
38  return XrdCl::URL(GetPath()).GetPath();
39 }
URL representation.
Definition: XrdClURL.hh:31
const std::string & GetPath() const
Get the path.
Definition: XrdClURL.hh:217
const char * GetPath()
Definition: XrdPfcIO.hh:53

References GetPath(), and XrdCl::URL::GetPath().

Referenced by XrdPfc::IOFile::IOFile().

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

◆ GetInput()

XrdOucCacheIO * IO::GetInput ( )

Definition at line 31 of file XrdPfcIO.cc.

32 {
33  return m_io;
34 }

Referenced by XrdPfc::IOFileBlock::Read().

+ Here is the caller graph for this function:

◆ GetLocation()

const char* XrdPfc::IO::GetLocation ( )
inline

Definition at line 44 of file XrdPfcIO.hh.

44 { return m_io->Location(false); }

Referenced by XrdPfc::File::AddIO(), XrdPfc::File::ioActive(), XrdPfc::File::ioUpdated(), and Update().

+ Here is the caller graph for this function:

◆ GetPath()

const char* XrdPfc::IO::GetPath ( )
inlineprotected

Definition at line 53 of file XrdPfcIO.hh.

53 { return m_io->Path(); }

Referenced by GetFilename().

+ Here is the caller graph for this function:

◆ GetTrace()

XrdSysTrace* XrdPfc::IO::GetTrace ( )
inline

Definition at line 45 of file XrdPfcIO.hh.

45 { return m_cache.GetTrace(); }
XrdSysTrace * GetTrace()
Definition: XrdPfc.hh:283

References XrdPfc::Cache::GetTrace(), and m_cache.

+ Here is the call graph for this function:

◆ ioActive()

virtual bool XrdPfc::IO::ioActive ( )
pure virtual

Implemented in XrdPfc::IOFileBlock, and XrdPfc::IOFile.

Referenced by Detach().

+ Here is the caller graph for this function:

◆ ObtainReadSid()

unsigned short XrdPfc::IO::ObtainReadSid ( )
inlineprotected

Definition at line 57 of file XrdPfcIO.hh.

57 { return m_read_seqid++; }

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

+ Here is the caller graph for this function:

◆ Path()

const char* XrdPfc::IO::Path ( )
inlineoverridevirtual

Original data source URL.

Implements XrdOucCacheIO.

Definition at line 24 of file XrdPfcIO.hh.

24 { return m_io->Path(); }

Referenced by Update().

+ Here is the caller graph for this function:

◆ RefreshLocation()

const char* XrdPfc::IO::RefreshLocation ( )
inlineprotected

Definition at line 55 of file XrdPfcIO.hh.

55 { return m_io->Location(true); }

Referenced by XrdPfc::IOFile::ioActive(), XrdPfc::IOFileBlock::ioActive(), and Update().

+ Here is the caller graph for this function:

◆ register_block_error()

bool XrdPfc::IO::register_block_error ( int  res)
inlineprotected

Definition at line 93 of file XrdPfcIO.hh.

93  {
94  return m_error_counts[res]++ == 0;
95  }
std::map< int, int > m_error_counts
Definition: XrdPfcIO.hh:89

References m_error_counts.

◆ register_incomplete_read()

bool XrdPfc::IO::register_incomplete_read ( )
inlineprotected

Definition at line 90 of file XrdPfcIO.hh.

90  {
91  return m_incomplete_count++ == 0;
92  }
int m_incomplete_count
Definition: XrdPfcIO.hh:88

References m_incomplete_count.

◆ Sync() [1/3]

int XrdPfc::IO::Sync ( )
inlineoverridevirtual

Perform an synchronous sync() operation.

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

Implements XrdOucCacheIO.

Definition at line 27 of file XrdPfcIO.hh.

27 { return 0; }

◆ Sync() [2/3]

virtual int XrdOucCacheIO::Sync
virtual

Perform an synchronous sync() operation.

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

Implements XrdOucCacheIO.

◆ Sync() [3/3]

virtual void XrdOucCacheIO::Sync
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.

Implements XrdOucCacheIO.

Definition at line 380 of file XrdOucCache.hh.

380 {iocb.Done(Sync());}
int Sync() override
Definition: XrdPfcIO.hh:27

◆ Trunc() [1/3]

virtual int XrdOucCacheIO::Trunc

Perform an synchronous trunc() operation.

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

◆ Trunc() [2/3]

int XrdPfc::IO::Trunc ( long long  offs)
inlineoverridevirtual

Perform an synchronous trunc() operation.

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

Implements XrdOucCacheIO.

Definition at line 30 of file XrdPfcIO.hh.

30 { return -ENOTSUP; }

◆ Trunc() [3/3]

virtual void XrdOucCacheIO::Trunc
inline

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

◆ Update()

void IO::Update ( XrdOucCacheIO iocp)
overridevirtual

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 from XrdOucCacheIO.

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

Definition at line 17 of file XrdPfcIO.cc.

18 {
19  SetInput(&iocp);
21  TRACE_PC(Info, const char* loc = GetLocation(),
22  "Update() " << Path() << " location: " <<
23  ((loc && loc[0] != 0) ? loc : "<not set>"));
24 }
#define TRACE_PC(act, pre_code, x)
Definition: XrdPfcTrace.hh:59
const char * Path() override
Original data source URL.
Definition: XrdPfcIO.hh:24
const char * RefreshLocation()
Definition: XrdPfcIO.hh:55
const char * GetLocation()
Definition: XrdPfcIO.hh:44
Status of cached file. Can be read from and written into a binary file.
Definition: XrdPfcInfo.hh:41

References GetLocation(), Path(), RefreshLocation(), and TRACE_PC.

Referenced by XrdPfc::IOFile::Update(), and XrdPfc::IOFileBlock::Update().

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

◆ Write() [1/3]

virtual int XrdOucCacheIO::Write

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.

◆ Write() [2/3]

int XrdPfc::IO::Write ( char *  buff,
long long  offs,
int  wlen 
)
inlineoverridevirtual

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.

Implements XrdOucCacheIO.

Definition at line 33 of file XrdPfcIO.hh.

33 { return -ENOTSUP; }

◆ Write() [3/3]

virtual void XrdOucCacheIO::Write
inline

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

Definition at line 447 of file XrdOucCache.hh.

448  {iocb.Done(Write(buff, offs, wlen));}
virtual int Write(char *buff, long long offs, int wlen)=0

Friends And Related Function Documentation

◆ File

friend class File
friend

Definition at line 80 of file XrdPfcIO.hh.

Member Data Documentation

◆ m_active_read_reqs

RAtomic_int XrdPfc::IO::m_active_read_reqs
protected

number of active read requests

Definition at line 70 of file XrdPfcIO.hh.

Referenced by XrdPfc::File::ioActive(), XrdPfc::IOFile::pgRead(), XrdPfc::IOFile::Read(), and XrdPfc::IOFile::ReadV().

◆ m_cache

Cache& XrdPfc::IO::m_cache
protected

reference to Cache object

Definition at line 50 of file XrdPfcIO.hh.

Referenced by XrdPfc::IOFileBlock::DetachFinalize(), and GetTrace().

◆ m_error_counts

std::map<int, int> XrdPfc::IO::m_error_counts
protected

Definition at line 89 of file XrdPfcIO.hh.

Referenced by XrdPfc::IOFile::DetachFinalize(), and register_block_error().

◆ m_incomplete_count

int XrdPfc::IO::m_incomplete_count {0}
protected

Definition at line 88 of file XrdPfcIO.hh.

Referenced by XrdPfc::IOFile::DetachFinalize(), and register_incomplete_read().

◆ m_traceID

const char* XrdPfc::IO::m_traceID
protected

Definition at line 51 of file XrdPfcIO.hh.


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