xrootd
XrdXrootdPgwCtl.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDPGWCTL_HH_
2 #define __XRDXROOTDPGWCTL_HH_
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d P g w C t l . h h */
6 /* */
7 /* (c) 2021 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <sys/uio.h>
33 
34 #include "XProtocol/XProtocol.hh"
35 #include "Xrd/XrdBuffer.hh"
36 #include "XrdSys/XrdSysPageSize.hh"
37 
38 class XrdXrootdFile;
39 
41 {
42 public:
43 
44 static const int crcSZ = sizeof(kXR_unt32);
45 static const int maxBSize = 1048576; // 1MB maximum buffer size
47 
50 
51 bool Advance();
52 
53 const char *boAdd(XrdXrootdFile *fP, kXR_int64 foffs,
54  int dlen=XrdProto::kXR_pgPageSZ);
55 
56 char *boInfo(int &boLen);
57 
58 struct iovec *FrameInfo(int &iovn, int &rdlen)
59  {rdlen = iovLen;
60  return ((iovn = iovNum) ? ioVec : 0);
61  }
62 
63 kXR_unt32 *FrameInfo(int &csNum, char *&buff, int &datalen, XrdBuffer *bP)
64  {if (bP->buff != dataBuff || bP->bsize != dataBLen
65  || !iovNum) return 0;
66  csNum = iovNum>>1;
67  buff = (char *)ioVec[1].iov_base;
68  datalen = iovLen - (crcSZ * csNum);
69  return csVec;
70  }
71 
72 char *FrameLeft(int k, int &dlen)
73  {k *= 2;
74  if (k >= iovNum) {dlen = 0; return 0;}
75  char *buff = (char *)ioVec[k+1].iov_base;
76  if (!k) dlen = iovLen - (iovNum/2*crcSZ);
77  else {int n = (iovNum - k)/2;
78  dlen = ((n-1)*XrdProto::kXR_pgPageSZ)
79  + ioVec[k+1].iov_len;
80  }
81  return buff;
82  }
83 
84 const char *Setup(XrdBuffer *buffP, kXR_int64 fOffs, int totlen);
85 
86 bool Suspend() {return isSusp;}
87 
88 bool Suspend(bool torf)
89  {bool curstate = isSusp;
90  isSusp = torf;
91  return curstate;
92  }
93 
94 
95  XrdXrootdPgwCtl(const char *id, int pid);
97 
98 private:
99 
100 ServerResponseBody_pgWrCSE cse; // cse.dlFirst, cse.dlLast
102 
103 static
104 const char *TraceID;
105 const char *ID;
106 char *dataBuff; // Pointer to data buffer
107 int dataBLen; // Actual length of buffer
108 int iovNum; // Number of elements in use
109 int iovRem; // Number of elements remaining to do
110 int iovLen; // Length of data read by the ioVec
111 short endLen; // Length of last segment if it is short
112 short boCount; // Elements in badOffs
113 short fixSRD; // ioVec[fixSRD] has short read
114 char pathID; // Associated path ID
115 bool isSusp; // Was suspended or not (1st time entry ctl)
116 kXR_unt32 csVec[maxIOVN/2]; // Checksums received
117 struct iovec ioVec[maxIOVN]; // Read vector
118 };
119 
120 #endif
kXR_unt32 csVec[maxIOVN/2]
Definition: XrdXrootdPgwCtl.hh:116
Definition: XProtocol.hh:1064
struct iovec ioVec[maxIOVN]
Definition: XrdXrootdPgwCtl.hh:117
static const int maxIOVN
Definition: XrdXrootdPgwCtl.hh:46
ServerResponseStatus resp
Definition: XrdXrootdPgwCtl.hh:48
static const int kXR_pgMaxEpr
Definition: XProtocol.hh:491
static const int maxBSize
Definition: XrdXrootdPgwCtl.hh:45
char * FrameLeft(int k, int &dlen)
Definition: XrdXrootdPgwCtl.hh:72
bool isSusp
Definition: XrdXrootdPgwCtl.hh:115
const char * ID
Definition: XrdXrootdPgwCtl.hh:105
bool Suspend(bool torf)
Definition: XrdXrootdPgwCtl.hh:88
ServerResponseBody_pgWrCSE cse
Definition: XrdXrootdPgwCtl.hh:100
Definition: XrdXrootdPgwCtl.hh:40
kXR_int64 badOffs[XrdProto::kXR_pgMaxEpr]
Definition: XrdXrootdPgwCtl.hh:101
bool Suspend()
Definition: XrdXrootdPgwCtl.hh:86
Definition: XProtocol.hh:1228
XrdXrootdPgwCtl(const char *id, int pid)
short fixSRD
Definition: XrdXrootdPgwCtl.hh:113
Definition: XrdXrootdFile.hh:99
int bsize
Definition: XrdBuffer.hh:46
char * boInfo(int &boLen)
ServerResponseBody_pgWrite info
Definition: XrdXrootdPgwCtl.hh:49
struct iovec * FrameInfo(int &iovn, int &rdlen)
Definition: XrdXrootdPgwCtl.hh:58
char pathID
Definition: XrdXrootdPgwCtl.hh:114
int dataBLen
Definition: XrdXrootdPgwCtl.hh:107
static const int kXR_pgPageSZ
Definition: XProtocol.hh:488
char * buff
Definition: XrdBuffer.hh:45
char * dataBuff
Definition: XrdXrootdPgwCtl.hh:106
short endLen
Definition: XrdXrootdPgwCtl.hh:111
unsigned int kXR_unt32
Definition: XPtypes.hh:90
short boCount
Definition: XrdXrootdPgwCtl.hh:112
const char * Setup(XrdBuffer *buffP, kXR_int64 fOffs, int totlen)
int iovRem
Definition: XrdXrootdPgwCtl.hh:109
int iovNum
Definition: XrdXrootdPgwCtl.hh:108
static const int crcSZ
Definition: XrdXrootdPgwCtl.hh:44
const char * boAdd(XrdXrootdFile *fP, kXR_int64 foffs, int dlen=XrdProto::kXR_pgPageSZ)
Definition: XProtocol.hh:1056
static const char * TraceID
Definition: XrdXrootdPgwCtl.hh:104
int iovLen
Definition: XrdXrootdPgwCtl.hh:110
kXR_unt32 * FrameInfo(int &csNum, char *&buff, int &datalen, XrdBuffer *bP)
Definition: XrdXrootdPgwCtl.hh:63
~XrdXrootdPgwCtl()
Definition: XrdXrootdPgwCtl.hh:96
long long kXR_int64
Definition: XPtypes.hh:98
Definition: XrdBuffer.hh:41