XRootD
XrdXrootdAioPgrw Class Reference

#include <XrdXrootdAioPgrw.hh>

+ Inheritance diagram for XrdXrootdAioPgrw:
+ Collaboration diagram for XrdXrootdAioPgrw:

Public Member Functions

 XrdXrootdAioPgrw (XrdXrootdAioTask *tP, XrdBuffer *bP)
 
 ~XrdXrootdAioPgrw ()
 
struct iovec * iov4Data (int &iovNum)
 
struct iovec * iov4Recv (int &iovNum)
 
struct iovec * iov4Send (int &iovNum, int &iovLen, bool cs2net=false)
 
bool noChkSums (bool reset=true)
 
void Recycle () override
 
int Setup2Recv (off_t offs, int dlen, const char *&eMsg)
 
int Setup2Send (off_t offs, int dlen, const char *&eMsg)
 
- Public Member Functions inherited from XrdXrootdAioBuff
 XrdXrootdAioBuff (XrdXrootdAioPgrw *pgrwP, XrdXrootdAioTask *tP, XrdBuffer *bP)
 
 XrdXrootdAioBuff (XrdXrootdAioTask *tP, XrdBuffer *bP)
 
void doneRead () override
 
void doneWrite () override
 
- Public Member Functions inherited from XrdSfsAio
 XrdSfsAio ()
 
virtual ~XrdSfsAio ()
 

Static Public Member Functions

static XrdXrootdAioPgrwAlloc (XrdXrootdAioTask *arp)
 
- Static Public Member Functions inherited from XrdXrootdAioBuff
static XrdXrootdAioBuffAlloc (XrdXrootdAioTask *arp)
 

Static Public Attributes

static const int acsSZ = aioSZ/XrdProto::kXR_pgPageSZ
 
static const int aioSZ = XrdXrootdPgrwAio::aioSZ
 

Additional Inherited Members

- Public Attributes inherited from XrdXrootdAioBuff
XrdXrootdAioBuffnext
 
XrdXrootdAioPgrw *const pgrwP
 
- Public Attributes inherited from XrdSfsAio
uint32_t * cksVec
 
ssize_t Result
 
struct aiocb sfsAio
 
const char * TIdent
 
- Protected Attributes inherited from XrdXrootdAioBuff
XrdBufferbuffP
 
XrdXrootdAioTaskreqP
 
- Static Protected Attributes inherited from XrdXrootdAioBuff
static const char * TraceID = "AioBuff"
 

Detailed Description

Definition at line 47 of file XrdXrootdAioPgrw.hh.

Constructor & Destructor Documentation

◆ XrdXrootdAioPgrw()

XrdXrootdAioPgrw::XrdXrootdAioPgrw ( XrdXrootdAioTask tP,
XrdBuffer bP 
)

Definition at line 80 of file XrdXrootdAioPgrw.cc.

81  : XrdXrootdAioBuff(this, tP, bP)
82 {
83  char *buff = bP->buff;
84  uint32_t *csV = csVec;
85 
86 // Fill out the iovec
87 //
88  for (int i = 1; i <= acsSZ<<1; i+= 2)
89  {ioVec[i ].iov_base = csV;
90  ioVec[i ].iov_len = csLen;
91  ioVec[i+1].iov_base = buff;
92  ioVec[i+1].iov_len = XrdProto::kXR_pgPageSZ;
93  csV++;
94  buff += XrdProto::kXR_pgPageSZ;
95  }
96 
97 // Complete initialization
98 //
99  Result = 0;
100  iovReset = 0;
101  cksVec = csVec;
102  TIdent = "AioPgrw";
103 }
char * buff
Definition: XrdBuffer.hh:45
uint32_t * cksVec
Definition: XrdSfsAio.hh:63
ssize_t Result
Definition: XrdSfsAio.hh:65
const char * TIdent
Definition: XrdSfsAio.hh:67
XrdXrootdAioBuff(XrdXrootdAioTask *tP, XrdBuffer *bP)
static const int acsSZ
static const int kXR_pgPageSZ
Definition: XProtocol.hh:494

References acsSZ, XrdBuffer::buff, XrdSfsAio::cksVec, XrdProto::kXR_pgPageSZ, XrdSfsAio::Result, and XrdSfsAio::TIdent.

Referenced by Alloc().

+ Here is the caller graph for this function:

◆ ~XrdXrootdAioPgrw()

XrdXrootdAioPgrw::~XrdXrootdAioPgrw ( )

Definition at line 109 of file XrdXrootdAioPgrw.cc.

110 {
111 // Recycle the buffer if we have one
112 //
113  if (buffP) BPool->Release(buffP);
114 }
void Release(XrdBuffer *bp)
Definition: XrdBuffer.cc:221
XrdBuffManager * BPool

References XrdXrootd::BPool, XrdXrootdAioBuff::buffP, and XrdBuffManager::Release().

+ Here is the call graph for this function:

Member Function Documentation

◆ Alloc()

XrdXrootdAioPgrw * XrdXrootdAioPgrw::Alloc ( XrdXrootdAioTask arp)
static

Definition at line 120 of file XrdXrootdAioPgrw.cc.

121 {
122  XrdXrootdAioBuff *aiobuff;
123 
124 // Obtain a preallocated aio object
125 //
126  fqMutex.Lock();
127  if ((aiobuff = fqFirst))
128  {fqFirst = aiobuff->next;
129  numFree--;
130  }
131  fqMutex.UnLock();
132 
133 // If we have no object, create a new one. Otherwise initialize n old one
134 //
135  if (!aiobuff)
136  {XrdBuffer *bP = BPool->Obtain(aioSZ);
137  if (!bP) return 0;
138  aiobuff = new XrdXrootdAioPgrw(arp, bP);
139  } else {
140  aiobuff->Result = 0;
141  aiobuff->cksVec = aiobuff->pgrwP->csVec;
142  aiobuff->pgrwP->reqP = arp;
143  }
144 
145 // Update aio counters
146 //
147  arp->urProtocol()->aioUpdate(1);
148 
149 // All done
150 //
151  return aiobuff->pgrwP;
152 }
XrdBuffer * Obtain(int bsz)
Definition: XrdBuffer.cc:140
XrdXrootdAioBuff * next
XrdXrootdAioPgrw *const pgrwP
XrdXrootdAioTask * reqP
static const int aioSZ
XrdXrootdAioPgrw(XrdXrootdAioTask *tP, XrdBuffer *bP)
XrdXrootdProtocol * urProtocol()
void aioUpdate(int val)

References XrdXrootdAioPgrw(), aioSZ, XrdXrootdProtocol::aioUpdate(), XrdXrootd::BPool, XrdSfsAio::cksVec, XrdXrootdAioBuff::next, XrdBuffManager::Obtain(), XrdXrootdAioBuff::pgrwP, XrdXrootdAioBuff::reqP, XrdSfsAio::Result, and XrdXrootdAioTask::urProtocol().

+ Here is the call graph for this function:

◆ iov4Data()

struct iovec* XrdXrootdAioPgrw::iov4Data ( int &  iovNum)
inline

Definition at line 54 of file XrdXrootdAioPgrw.hh.

54 {iovNum = csNum<<1; return &ioVec[1];}

◆ iov4Recv()

struct iovec * XrdXrootdAioPgrw::iov4Recv ( int &  iovNum)

Definition at line 158 of file XrdXrootdAioPgrw.cc.

159 {
160 // Readjust ioVec as needed
161 //
162  if (aioSZ != (int)sfsAio.aio_nbytes)
163  {int fLen, lLen;
165  fLen, lLen);
166  ioVec[2].iov_len = fLen;
167  if (csNum > 1 && lLen != XrdProto::kXR_pgPageSZ)
168  {iovReset = csNum<<1;
169  ioVec[iovReset].iov_len = lLen;
170  }
171  } else csNum = acsSZ;
172 
173 // Return the iovec reception args
174 //
175  iovNum = (csNum<<1);
176  return &ioVec[1];
177 }
off_t aio_offset
Definition: XrdSfsAio.hh:49
size_t aio_nbytes
Definition: XrdSfsAio.hh:48
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
struct aiocb sfsAio
Definition: XrdSfsAio.hh:62

References acsSZ, aiocb::aio_nbytes, aiocb::aio_offset, aioSZ, XrdOucPgrwUtils::csNum(), XrdProto::kXR_pgPageSZ, and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

◆ iov4Send()

struct iovec * XrdXrootdAioPgrw::iov4Send ( int &  iovNum,
int &  iovLen,
bool  cs2net = false 
)

Definition at line 183 of file XrdXrootdAioPgrw.cc.

184 {
185  int fLen, lLen;
186 
187 // Recalculate the iovec values for first and last read and summary values
188 //
189  if (Result > 0)
190  {csNum = XrdOucPgrwUtils::csNum(sfsAio.aio_offset, Result, fLen, lLen);
191  iovNum = (csNum<<1) + 1;
192  iovLen = Result + (csNum * sizeof(uint32_t));
193  ioVec[2].iov_len = fLen;
194  if (csNum > 1 && lLen != XrdProto::kXR_pgPageSZ)
195  {iovReset = csNum<<1;
196  ioVec[iovReset].iov_len = lLen;
197  }
198  } else csNum = 0;
199 
200 // Convert checksums to net order if so requested
201 //
202  if (cs2net) for (int i = 0; i < csNum; i++) csVec[i] = htonl(csVec[i]);
203 
204 // Return the iovec
205 //
206  return ioVec;
207 }

References aiocb::aio_offset, XrdOucPgrwUtils::csNum(), XrdProto::kXR_pgPageSZ, XrdSfsAio::Result, and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

◆ noChkSums()

bool XrdXrootdAioPgrw::noChkSums ( bool  reset = true)
inline

Definition at line 60 of file XrdXrootdAioPgrw.hh.

61  {bool retval = cksVec == 0;
62  if (retval && reset) cksVec = csVec;
63  return retval;
64  }

References XrdSfsAio::cksVec.

◆ Recycle()

void XrdXrootdAioPgrw::Recycle ( void  )
overridevirtual

Reimplemented from XrdXrootdAioBuff.

Definition at line 213 of file XrdXrootdAioPgrw.cc.

214 {
215 // Do some tracing
216 //
217  TRACE(FSAIO, " Recycle " <<sfsAio.aio_nbytes<<'@'
218  <<sfsAio.aio_offset<<" numF="<<numFree);
219 
220 // Update aio counters
221 //
222  reqP->urProtocol()->aioUpdate(-1);
223 
224 // Place the object on the free queue if possible
225 //
226  fqMutex.Lock();
227  if (numFree >= maxKeep)
228  {fqMutex.UnLock();
229  delete this;
230  } else {
231  next = fqFirst;
232  fqFirst = this;
233  numFree++;
234  fqMutex.UnLock();
235  }
236 }
#define TRACE(act, x)
Definition: XrdTrace.hh:63

References aiocb::aio_nbytes, aiocb::aio_offset, XrdXrootdProtocol::aioUpdate(), XrdXrootdAioBuff::next, XrdXrootdAioBuff::reqP, XrdSfsAio::sfsAio, TRACE, and XrdXrootdAioTask::urProtocol().

+ Here is the call graph for this function:

◆ Setup2Recv()

int XrdXrootdAioPgrw::Setup2Recv ( off_t  offs,
int  dlen,
const char *&  eMsg 
)

Definition at line 242 of file XrdXrootdAioPgrw.cc.

243 {
245 
246 // Reset any truncated segement in the iov vector
247 //
248  if (iovReset)
249  {ioVec[iovReset].iov_len = XrdProto::kXR_pgPageSZ;
250  iovReset = 0;
251  }
252 
253 // Get the layout for the iovec
254 //
255  if (!(csNum = XrdOucPgrwUtils::recvLayout(layout, offs, dlen, aioSZ)))
256  {eMsg = layout.eWhy;
257  return 0;
258  }
259  eMsg = 0;
260 
261 // Set the length of the first and last segments. Note that our iovec has
262 // an extra leading element meant for writing to the network.
263 //
264  ioVec[2].iov_len = layout.fLen;
265  if (csNum > 1 && layout.lLen < XrdProto::kXR_pgPageSZ)
266  {iovReset = csNum<<1;
267  ioVec[iovReset].iov_len = layout.lLen;
268  }
269 
270 // Setup for actual writing of the data
271 //
272  sfsAio.aio_buf = ioVec[2].iov_base = buffP->buff + layout.bOffset;
273  sfsAio.aio_nbytes = layout.dataLen;
274  sfsAio.aio_offset = offs;
275 
276 // Return how much we can read from the socket
277 //
278  return layout.sockLen;
279 }
#define eMsg(x)
void * aio_buf
Definition: XrdSfsAio.hh:47
off_t bOffset
Buffer offset to apply iov[1].iov_base.
int dataLen
Total number of filesys bytes the iovec will handle.
int fLen
Length to use for iov[1].iov_len.
int sockLen
Total number of network bytes the iovec will handle.
const char * eWhy
Reason for failure when zero is returned.
int lLen
Length to use for iov[csnum*2-1].iov_len)
static int recvLayout(Layout &layout, off_t offs, int dlen, int bsz=0)
Compute the layout for an iovec that receives network bytes applying.

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, aioSZ, XrdOucPgrwUtils::Layout::bOffset, XrdBuffer::buff, XrdXrootdAioBuff::buffP, XrdOucPgrwUtils::Layout::dataLen, eMsg, XrdOucPgrwUtils::Layout::eWhy, XrdOucPgrwUtils::Layout::fLen, XrdProto::kXR_pgPageSZ, XrdOucPgrwUtils::Layout::lLen, XrdOucPgrwUtils::recvLayout(), XrdSfsAio::sfsAio, and XrdOucPgrwUtils::Layout::sockLen.

+ Here is the call graph for this function:

◆ Setup2Send()

int XrdXrootdAioPgrw::Setup2Send ( off_t  offs,
int  dlen,
const char *&  eMsg 
)

Definition at line 285 of file XrdXrootdAioPgrw.cc.

286 {
288 
289 // Reset any truncated segement in the iov vector
290 //
291  if (iovReset)
292  {ioVec[iovReset].iov_len = XrdProto::kXR_pgPageSZ;
293  iovReset = 0;
294  }
295 
296 // Get the layout for the iovec
297 //
298  if (!(csNum = XrdOucPgrwUtils::sendLayout(layout, offs, dlen, aioSZ)))
299  {eMsg = layout.eWhy;
300  return 0;
301  }
302  eMsg = 0;
303 
304 // Set the length of the first and last segments. Note that our iovec has
305 // an extra leading element meant for writing to the network.
306 //
307  ioVec[2].iov_len = layout.fLen;
308  if (csNum > 1 && layout.lLen < XrdProto::kXR_pgPageSZ)
309  {iovReset = csNum<<1;
310  ioVec[iovReset].iov_len = layout.lLen;
311  }
312 
313 // Setup for actual writing of the data
314 //
315  sfsAio.aio_buf = ioVec[2].iov_base = buffP->buff + layout.bOffset;
316  sfsAio.aio_nbytes = layout.dataLen;
317  sfsAio.aio_offset = offs;
318 
319 // Return how much we can write to the socket
320 //
321  return layout.dataLen;
322 }
static int sendLayout(Layout &layout, off_t offs, int dlen, int bsz=0)

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, aioSZ, XrdOucPgrwUtils::Layout::bOffset, XrdBuffer::buff, XrdXrootdAioBuff::buffP, XrdOucPgrwUtils::Layout::dataLen, eMsg, XrdOucPgrwUtils::Layout::eWhy, XrdOucPgrwUtils::Layout::fLen, XrdProto::kXR_pgPageSZ, XrdOucPgrwUtils::Layout::lLen, XrdOucPgrwUtils::sendLayout(), and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

Member Data Documentation

◆ acsSZ

const int XrdXrootdAioPgrw::acsSZ = aioSZ/XrdProto::kXR_pgPageSZ
static

Definition at line 76 of file XrdXrootdAioPgrw.hh.

Referenced by XrdXrootdAioPgrw(), and iov4Recv().

◆ aioSZ

const int XrdXrootdAioPgrw::aioSZ = XrdXrootdPgrwAio::aioSZ
static

Definition at line 75 of file XrdXrootdAioPgrw.hh.

Referenced by Alloc(), iov4Recv(), Setup2Recv(), and Setup2Send().


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