XRootD
XrdXrootdNormAio Class Reference

#include <XrdXrootdNormAio.hh>

+ Inheritance diagram for XrdXrootdNormAio:
+ Collaboration diagram for XrdXrootdNormAio:

Public Member Functions

void DoIt () override
 
void Read (long long offs, int dlen) override
 
void Recycle (bool release) override
 
int Write (long long offs, int dlen) override
 
- Public Member Functions inherited from XrdXrootdAioTask
void Completed (XrdXrootdAioBuff *aioP)
 
const char * ID ()
 
void Init (XrdXrootdProtocol *protP, XrdXrootdResponse &resp, XrdXrootdFile *fP)
 
XrdXrootdProtocolurProtocol ()
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Static Public Member Functions

static XrdXrootdNormAioAlloc (XrdXrootdProtocol *protP, XrdXrootdResponse &resp, XrdXrootdFile *fP)
 

Additional Inherited Members

- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 
- Protected Member Functions inherited from XrdXrootdAioTask
 XrdXrootdAioTask (const char *what="aio request")
 
virtual ~XrdXrootdAioTask ()
 
bool Drain ()
 
int gdDone () override
 
void gdFail () override
 
XrdXrootdAioBuffgetBuff (bool wait)
 
void SendError (int rc, const char *eText)
 
void SendFSError (int rc)
 
bool Validate (XrdXrootdAioBuff *aioP)
 
- Protected Attributes inherited from XrdXrootdAioTask
union {
XrdXrootdNormAionextNorm
 
XrdXrootdPgrwAionextPgrw
 
XrdXrootdAioTasknextTask
 
}; 
 
union {
XrdXrootdAioBufffinalRead
 
XrdXrootdAioBuffpendWrite
 
}; 
 
XrdSysMutex aioMutex
 
XrdSysCondVar2 aioReady
 
char aioState
 
XrdXrootdFiledataFile
 
int dataLen
 
XrdLinkdataLink
 
off_t dataOffset
 
off_t highOffset
 
RAtomic_uchar inFlight
 
RAtomic_bool isDone
 
XrdXrootdAioBuffpendQ
 
XrdXrootdAioBuffpendQEnd
 
XrdXrootdProtocolProtocol
 
XrdXrootdResponse Response
 
char Status
 
- Static Protected Attributes inherited from XrdXrootdAioTask
static const int aioDead = 0x01
 
static const int aioHeld = 0x02
 
static const int aioPage = 0x04
 
static const int aioRead = 0x08
 
static const int aioSchd = 0x10
 
static const int Offline = 0
 
static const int Running = 1
 
static const char * TraceID = "AioTask"
 
static const int Waiting = 2
 

Detailed Description

Definition at line 38 of file XrdXrootdNormAio.hh.

Member Function Documentation

◆ Alloc()

XrdXrootdNormAio * XrdXrootdNormAio::Alloc ( XrdXrootdProtocol protP,
XrdXrootdResponse resp,
XrdXrootdFile fP 
)
static

Definition at line 84 of file XrdXrootdNormAio.cc.

87 {
88  XrdXrootdNormAio *reqP;
89 
90 // Obtain a preallocated aio request object
91 //
92  fqMutex.Lock();
93  if ((reqP = fqFirst))
94  {fqFirst = reqP->nextNorm;
95  numFree--;
96  }
97  fqMutex.UnLock();
98 
99 // If we have no object, create a new one
100 //
101  if (!reqP) reqP = new XrdXrootdNormAio;
102 
103 // Initialize the object and return it
104 //
105  reqP->Init(protP, resp, fP);
106  reqP->nextNorm = 0;
107  return reqP;
108 }
void Init(XrdXrootdProtocol *protP, XrdXrootdResponse &resp, XrdXrootdFile *fP)

References XrdXrootdAioTask::Init().

+ Here is the call graph for this function:

◆ DoIt()

void XrdXrootdNormAio::DoIt ( )
overridevirtual

Implements XrdJob.

Definition at line 375 of file XrdXrootdNormAio.cc.

376 {
377 // Reads run disconnected as they will never read from the link.
378 //
379  if (aioState & aioRead) CopyF2L();
380 }
static const int aioRead

◆ Read()

void XrdXrootdNormAio::Read ( long long  offs,
int  dlen 
)
overridevirtual

Implements XrdXrootdAioTask.

Definition at line 386 of file XrdXrootdNormAio.cc.

387 {
388 
389 // Setup the copy from the file to the network
390 //
391  dataOffset = highOffset = sendOffset = offs;
392  dataLen = dlen;
393  aioState = aioRead;
394 
395 // Reads run disconnected and are self-terminating, so we need to increase the
396 // refcount for the link we will be using to prevent it from disapearing.
397 // Recycle will decrement it but does so only for reads. We always update
398 // the file refcount and increase the request count.
399 //
400  dataLink->setRef(1);
401  dataFile->Ref(1);
402  Protocol->aioUpdReq(1);
403 
404 // Schedule ourselves to run this asynchronously and return
405 //
406  dataFile->aioFob->Schedule(this);
407 }
void Schedule(XrdXrootdAioTask *aioP)
XrdXrootdFile * dataFile
XrdXrootdProtocol * Protocol
void Ref(int num)
XrdXrootdAioFob * aioFob
void aioUpdReq(int val)

◆ Recycle()

void XrdXrootdNormAio::Recycle ( bool  release)
overridevirtual

Implements XrdXrootdAioTask.

Definition at line 413 of file XrdXrootdNormAio.cc.

414 {
415 // Update request count, file and link reference count
416 //
417  if (!(aioState & aioHeld))
418  {Protocol->aioUpdReq(-1);
419  if (aioState & aioRead)
420  {dataFile->Ref(-1);
421  dataLink->setRef(-1);
422  }
423  aioState |= aioHeld;
424  }
425 
426 // Do some tracing and reset reorder counter
427 //
428  TRACEP(FSAIO,"aio"<<(aioState & aioRead ? 'R' : 'W')<<" recycle"
429  <<(release ? "" : " hold")<<"; reorders="<<reorders
430  <<" D-S="<<isDone<<'-'<<int(Status));
431  reorders = 0;
432 
433 // Place the object on the free queue if possible
434 //
435  if (release)
436  {fqMutex.Lock();
437  if (numFree >= maxKeep)
438  {fqMutex.UnLock();
439  delete this;
440  } else {
441  nextNorm = fqFirst;
442  fqFirst = this;
443  numFree++;
444  fqMutex.UnLock();
445  }
446  }
447 }
#define TRACEP(act, x)
static const int aioHeld

References TRACEP.

◆ Write()

int XrdXrootdNormAio::Write ( long long  offs,
int  dlen 
)
overridevirtual

Implements XrdXrootdAioTask.

Definition at line 479 of file XrdXrootdNormAio.cc.

480 {
481 // Update request count. Note that dataLink and dataFile references are
482 // handled outboard as writes are inextricably tied to the data link.
483 //
484  Protocol->aioUpdReq(1);
485 
486 // Setup the copy from the network to the file
487 //
488  aioState &= ~aioRead;
489  dataOffset = highOffset = offs;
490  dataLen = dlen;
491 
492 // Since this thread can't do anything else since it's blocked by the socket
493 // we simply initiate the write operation via a simulated getData() callback.
494 //
495  return gdDone();
496 }
int gdDone() override

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