XRootD
Loading...
Searching...
No Matches
XrdXrootdPgwCtl Class Reference

#include <XrdXrootdPgwCtl.hh>

+ Inheritance diagram for XrdXrootdPgwCtl:
+ Collaboration diagram for XrdXrootdPgwCtl:

Public Member Functions

 XrdXrootdPgwCtl (int pid)
 
 ~XrdXrootdPgwCtl ()
 
bool Advance ()
 
kXR_unt32FrameInfo (int &csNum, char *&buff, int &datalen, XrdBuffer *bP)
 
struct iovec * FrameInfo (int &iovn, int &rdlen)
 
char * FrameLeft (int k, int &dlen)
 
const char * Setup (XrdBuffer *buffP, kXR_int64 fOffs, int totlen)
 
- Public Member Functions inherited from XrdXrootdPgwBadCS
 XrdXrootdPgwBadCS (int pid=0)
 
 ~XrdXrootdPgwBadCS ()
 
const char * boAdd (XrdXrootdFile *fP, kXR_int64 foffs, int dlen=XrdProto::kXR_pgPageSZ)
 
char * boInfo (int &boLen)
 
void boReset ()
 

Public Attributes

ServerResponseBody_pgWrite info
 
ServerResponseStatus resp
 

Static Public Attributes

static const int crcSZ = sizeof(kXR_unt32)
 
static const int maxBSize = 1048576
 
static const int maxIOVN = maxBSize/XrdProto::kXR_pgPageSZ*2
 

Detailed Description

Definition at line 41 of file XrdXrootdPgwCtl.hh.

Constructor & Destructor Documentation

◆ XrdXrootdPgwCtl()

XrdXrootdPgwCtl::XrdXrootdPgwCtl ( int pid)

Definition at line 54 of file XrdXrootdPgwCtl.cc.

55 : XrdXrootdPgwBadCS(pid), dataBuff(0), dataBLen(0), fixSRD(0)
56{
57
58// Clear the response area
59//
60 memset(&resp, 0, sizeof(resp));
61
62// Setup response fields that stay constant for the life of the object
63//
64 resp.bdy.requestid = kXR_pgwrite - kXR_1stRequest;
65 resp.bdy.resptype = XrdProto::kXR_FinalResult; // No partials
66
67// Setup the iovec assuming full usage
68//
69 kXR_unt32 *csP = csVec;
70 for (int i = 0; i < maxIOVN; i += 2)
71 {ioVec[i ].iov_base = csP++;
72 ioVec[i ].iov_len = sizeof(kXR_unt32);
73 ioVec[i+1].iov_len = pgPageSize;
74 };
75}
@ kXR_1stRequest
Definition XProtocol.hh:111
@ kXR_pgwrite
Definition XProtocol.hh:138
unsigned int kXR_unt32
Definition XPtypes.hh:90
ServerResponseStatus resp
static const int maxIOVN
@ kXR_FinalResult

References XrdXrootdPgwBadCS::XrdXrootdPgwBadCS(), kXR_1stRequest, XrdProto::kXR_FinalResult, kXR_pgwrite, maxIOVN, and resp.

+ Here is the call graph for this function:

◆ ~XrdXrootdPgwCtl()

XrdXrootdPgwCtl::~XrdXrootdPgwCtl ( )
inline

Definition at line 84 of file XrdXrootdPgwCtl.hh.

84{}

Member Function Documentation

◆ Advance()

bool XrdXrootdPgwCtl::Advance ( )

Definition at line 81 of file XrdXrootdPgwCtl.cc.

82{
83// Check if we have anything to advance here
84//
85 if (iovRem <= 0)
86 {iovNum = 0;
87 iovLen = 0;
88 return false;
89 }
90
91// Readjust values for first data iov element as the previous one may not have
92// bin for a full page (unaligned read). We just do it categorically.
93//
94 ioVec[1].iov_base = dataBuff;
95 ioVec[1].iov_len = pgPageSize;
96
97// Compute number of iovec element we will use for the next read.
98//
99 if (iovRem > iovNum) iovRem -= iovNum;
100 else {iovNum = iovRem;
101 iovRem = 0;
102 if (endLen)
103 {ioVec[iovNum-1].iov_len = endLen;
104 fixSRD = iovNum-1;
105 }
106 }
107
108// Compute bytes read by this frame
109//
110 int n = iovNum>>1;
111 iovLen = ioVec[iovNum-1].iov_len + (n*crcSZ);
112 if (n > 1) iovLen += (n-1)*pgPageSize;
113
114// Indicate there is more to do
115//
116 return true;
117}
static const int crcSZ

References crcSZ.

◆ FrameInfo() [1/2]

kXR_unt32 * XrdXrootdPgwCtl::FrameInfo ( int & csNum,
char *& buff,
int & datalen,
XrdBuffer * bP )
inline

Definition at line 59 of file XrdXrootdPgwCtl.hh.

60 {if (bP->buff != dataBuff || bP->bsize != dataBLen
61 || !iovNum) return 0;
62 csNum = iovNum>>1;
63 buff = (char *)ioVec[1].iov_base;
64 datalen = iovLen - (crcSZ * csNum);
65 return csVec;
66 }
char * buff
Definition XrdBuffer.hh:45

References XrdBuffer::bsize, XrdBuffer::buff, and crcSZ.

◆ FrameInfo() [2/2]

struct iovec * XrdXrootdPgwCtl::FrameInfo ( int & iovn,
int & rdlen )
inline

Definition at line 54 of file XrdXrootdPgwCtl.hh.

55 {rdlen = iovLen;
56 return ((iovn = iovNum) ? ioVec : 0);
57 }

◆ FrameLeft()

char * XrdXrootdPgwCtl::FrameLeft ( int k,
int & dlen )
inline

Definition at line 68 of file XrdXrootdPgwCtl.hh.

69 {k *= 2;
70 if (k >= iovNum) {dlen = 0; return 0;}
71 char *buff = (char *)ioVec[k+1].iov_base;
72 if (!k) dlen = iovLen - (iovNum/2*crcSZ);
73 else {int n = (iovNum - k)/2;
74 dlen = ((n-1)*XrdProto::kXR_pgPageSZ)
75 + ioVec[k+1].iov_len;
76 }
77 return buff;
78 }
static const int kXR_pgPageSZ
Definition XProtocol.hh:494

References crcSZ, and XrdProto::kXR_pgPageSZ.

◆ Setup()

const char * XrdXrootdPgwCtl::Setup ( XrdBuffer * buffP,
kXR_int64 fOffs,
int totlen )

Definition at line 123 of file XrdXrootdPgwCtl.cc.

124{
125 XrdOucPgrwUtils::Layout layout;
126 int csNum, iovMax;
127
128// Reset short length in the iovec from the last use.
129//
130 if (fixSRD)
131 {ioVec[fixSRD].iov_len = pgPageSize;
132 fixSRD = 0;
133 }
134
135// Compute the layout parameters for the complete read (done once)
136//
137 if (!(csNum = XrdOucPgrwUtils::recvLayout(layout, fOffs, totlen)))
138 return layout.eWhy;
139
140// Compute the maximum number of iov entries for the real buffer size
141//
142 if (buffP->bsize >= maxBSize) iovMax = (maxBSize/XrdProto::kXR_pgPageSZ)*2;
143 else iovMax = (buffP->bsize/XrdProto::kXR_pgPageSZ)*2;
144
145// Verify the logic here, under no circumstance should iovMax be zero
146//
147 if (!iovMax) return "PgwCtl logic error detected; buffer is too small";
148
149// If the buffer has changed, then we must update buffer addresses in the iovec
150// Note that buffer sizes are always a power of 1K (i.e. 1, 2, 4, 8, etc).
151// However, the caller is on the hook to make the buffer no less than 4K.
152//
153 if (buffP->buff != dataBuff || buffP->bsize != dataBLen)
154 {char *dP;
155 dP = dataBuff = buffP->buff; dataBLen = buffP->bsize;
156 for (int i = 1; i < iovMax; i +=2)
157 {ioVec[i].iov_base = dP;
159 }
160 }
161
162// Setup control information and preset the initial read.
163//
164 ioVec[1].iov_base = buffP->buff + layout.bOffset;
165 ioVec[1].iov_len = layout.fLen;
166
167// Now setup for subsequent reads which we may not need.
168//
169 iovRem = csNum<<1;
170 if (iovRem > iovMax)
171 {iovNum = iovMax;
172 iovLen = layout.fLen + ((iovMax/2-1)*pgPageSize) + (iovMax/2*crcSZ);
173 endLen = layout.lLen;
174 } else {
175 iovNum = iovRem;
176 iovLen = layout.sockLen;
177 endLen = 0;
178 if (layout.lLen)
179 {ioVec[iovNum-1].iov_len = layout.lLen;
180 fixSRD = iovNum-1;
181 }
182 }
183 iovRem -= iovNum;
184 lenLeft = layout.sockLen - iovLen;
185
186// Reset remaining fields
187//
188 boReset();
189 info.offset = htonll(fOffs);
190 return 0;
191}
off_t bOffset
Buffer offset to apply iov[1].iov_base.
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)
static const int maxBSize
ServerResponseBody_pgWrite info

References XrdOucPgrwUtils::Layout::bOffset, XrdXrootdPgwBadCS::boReset(), XrdBuffer::bsize, XrdBuffer::buff, crcSZ, XrdOucPgrwUtils::Layout::eWhy, XrdOucPgrwUtils::Layout::fLen, info, XrdProto::kXR_pgPageSZ, XrdOucPgrwUtils::Layout::lLen, maxBSize, XrdOucPgrwUtils::recvLayout(), and XrdOucPgrwUtils::Layout::sockLen.

+ Here is the call graph for this function:

Member Data Documentation

◆ crcSZ

const int XrdXrootdPgwCtl::crcSZ = sizeof(kXR_unt32)
static

Definition at line 45 of file XrdXrootdPgwCtl.hh.

Referenced by Advance(), FrameInfo(), FrameLeft(), and Setup().

◆ info

ServerResponseBody_pgWrite XrdXrootdPgwCtl::info

Definition at line 50 of file XrdXrootdPgwCtl.hh.

Referenced by Setup().

◆ maxBSize

const int XrdXrootdPgwCtl::maxBSize = 1048576
static

Definition at line 46 of file XrdXrootdPgwCtl.hh.

Referenced by Setup().

◆ maxIOVN

const int XrdXrootdPgwCtl::maxIOVN = maxBSize/XrdProto::kXR_pgPageSZ*2
static

Definition at line 47 of file XrdXrootdPgwCtl.hh.

Referenced by XrdXrootdPgwCtl().

◆ resp

ServerResponseStatus XrdXrootdPgwCtl::resp

Definition at line 49 of file XrdXrootdPgwCtl.hh.

Referenced by XrdXrootdPgwCtl().


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