xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdRmcData.hh
Go to the documentation of this file.
1 #ifndef __XRDRMCDATA_HH__
2 #define __XRDRMCDATA_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d R m c D a t a . h h */
6 /* */
7 /* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 /* The XrdRmcData object defines a remanufactured XrdOucCacheIO object and
34  is used to front a XrdOucCacheIO object with an XrdRmcReal object.
35 */
36 
37 #include "XrdOuc/XrdOucCache.hh"
38 #include "XrdRmc/XrdRmcReal.hh"
39 #include "XrdSys/XrdSysPthread.hh"
40 #include "XrdSys/XrdSysXSLock.hh"
41 
42 class XrdRmcData : public XrdOucCacheIO
43 {
44 public:
45 
46 bool Detach(XrdOucCacheIOCD &iocd);
47 
48 long long FSize() {return (ioObj ? ioObj->FSize() : 0);}
49 
50 const char *Path() {return ioObj->Path();}
51 
52 void Preread();
53 
54 void Preread(aprParms &Parms);
55 
56 void Preread(long long Offs, int rLen, int Opts=0);
57 
58 int Read (char *Buffer, long long Offset, int Length);
59 
60 static int setAPR(aprParms &Dest, aprParms &Src, int pSize);
61 
62 int Sync() {return 0;} // We only support write-through for now
63 
64 int Trunc(long long Offset);
65 
66 int Write(char *Buffer, long long Offset, int Length);
67 
69  long long vn, int opts);
70 
71 private:
73 void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0);
74 int Read (XrdOucCacheStats &Now,
75  char *Buffer, long long Offs, int Length);
76 
77 // The following is for read/write support
78 //
79 class MrSw
80 {
81 public:
82 inline void UnLock() {if (myLock) {myLock->UnLock(myUsage); myLock = 0;}}
83 
84  MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage) : myUsage(usage)
85  {if ((myLock = lP)) lP->Lock(usage);}
87 
88 private:
91 };
92 
93 // Statics per connection
94 //
96 
97 // The following supports MRSW serialization
98 //
100 XrdSysXSLock *pPLock; // 0 if no preread lock required
101 XrdSysXSLock *rPLock; // 0 if no read lock required
102 XrdSysXSLock *wPLock; // 0 if no write lock required
105 
109 long long VNum;
110 long long SegSize;
111 long long OffMask;
112 long long SegShft;
114 char isFIS;
115 char isRW;
116 char Debug;
117 
118 static const int okRW = 1;
119 static const int xqRW = 2;
120 
121 // Preread Control Area
122 //
125 
126 long long prNSS; // Next Sequential Segment for maxi prereads
127 
128 static const int prRRMax= 5;
129 long long prRR[prRRMax]; // Recent reads
130 int prRRNow; // Pointer to next entry to use
131 
132 static const int prMax = 8;
133 static const int prRun = 1; // Status in prActive (running)
134 static const int prWait = 2; // Status in prActive (waiting)
135 
136 static const int prLRU = 1; // Status in prOpt (set LRU)
137 static const int prSUSE = 2; // Status in prOpt (set Single Use)
138 static const int prSKIP = 3; // Status in prOpt (skip entry)
139 
140 aprParms Apr;
141 long long prCalc;
142 long long prBeg[prMax];
143 long long prEnd[prMax];
144 int prNext;
145 int prFree;
146 int prPerf;
147 char prOpt[prMax];
148 char prOK;
149 char prActive;
150 char prAuto;
151 };
152 #endif
XrdRmcReal::prTask prReq
Definition: XrdRmcData.hh:123
long long prEnd[prMax]
Definition: XrdRmcData.hh:143
int Read(char *Buffer, long long Offset, int Length)
char prAuto
Definition: XrdRmcData.hh:150
char prOK
Definition: XrdRmcData.hh:148
int prNext
Definition: XrdRmcData.hh:144
Definition: XrdRmcReal.hh:122
long long prNSS
Definition: XrdRmcData.hh:126
Definition: XrdOucCache.hh:104
long long OffMask
Definition: XrdRmcData.hh:111
XrdSysSemaphore * prStop
Definition: XrdRmcData.hh:124
void Preread()
void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0)
Definition: XrdSysXSLock.hh:44
XrdSysXSLock rwLock
Definition: XrdRmcData.hh:99
static const int okRW
Definition: XrdRmcData.hh:118
static const int prSUSE
Definition: XrdRmcData.hh:137
static const int xqRW
Definition: XrdRmcData.hh:119
char prActive
Definition: XrdRmcData.hh:149
long long SegSize
Definition: XrdRmcData.hh:110
int prPerf
Definition: XrdRmcData.hh:146
long long VNum
Definition: XrdRmcData.hh:109
Definition: XrdOucCache.hh:81
XrdSysXSLock * myLock
Definition: XrdRmcData.hh:89
char isFIS
Definition: XrdRmcData.hh:114
XrdSysXSLock * rPLock
Definition: XrdRmcData.hh:101
Definition: XrdSysPthread.hh:164
int prFree
Definition: XrdRmcData.hh:145
XrdSysXS_Type pPLopt
Definition: XrdRmcData.hh:103
static const int prSKIP
Definition: XrdRmcData.hh:138
void UnLock(const XrdSysXS_Type usage=xs_None)
int Write(char *Buffer, long long Offset, int Length)
Definition: XrdRmcData.hh:79
virtual const char * Path()=0
long long prRR[prRRMax]
Definition: XrdRmcData.hh:129
long long prCalc
Definition: XrdRmcData.hh:141
aprParms Apr
Definition: XrdRmcData.hh:140
XrdSysXS_Type myUsage
Definition: XrdRmcData.hh:90
Definition: XrdSysPthread.hh:493
static const int prMax
Definition: XrdRmcData.hh:132
XrdSysMutex DMutex
Definition: XrdRmcData.hh:106
XrdOucCacheStats Statistics
Definition: XrdRmcData.hh:95
const char * Path()
Definition: XrdRmcData.hh:50
XrdRmcReal * Cache
Definition: XrdRmcData.hh:107
long long prBeg[prMax]
Definition: XrdRmcData.hh:142
static const int prRRMax
Definition: XrdRmcData.hh:128
char prOpt[prMax]
Definition: XrdRmcData.hh:147
int Trunc(long long Offset)
Definition: XrdRmcData.hh:42
XrdSysXSLock * pPLock
Definition: XrdRmcData.hh:100
void Lock(const XrdSysXS_Type usage)
int maxCache
Definition: XrdRmcData.hh:113
~XrdRmcData()
Definition: XrdRmcData.hh:72
static const int prRun
Definition: XrdRmcData.hh:133
XrdSysXSLock * wPLock
Definition: XrdRmcData.hh:102
void UnLock()
Definition: XrdRmcData.hh:82
XrdSysXS_Type rPLopt
Definition: XrdRmcData.hh:104
Definition: XrdOucCacheStats.hh:43
MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage)
Definition: XrdRmcData.hh:84
XrdRmcData(XrdRmcReal *cP, XrdOucCacheIO *ioP, long long vn, int opts)
virtual long long FSize()=0
bool Detach(XrdOucCacheIOCD &iocd)
char Debug
Definition: XrdRmcData.hh:116
~MrSw()
Definition: XrdRmcData.hh:86
char isRW
Definition: XrdRmcData.hh:115
XrdOucCacheIO * ioObj
Definition: XrdRmcData.hh:108
long long SegShft
Definition: XrdRmcData.hh:112
int Sync()
Definition: XrdRmcData.hh:62
long long FSize()
Definition: XrdRmcData.hh:48
int prRRNow
Definition: XrdRmcData.hh:130
Definition: XrdRmcReal.hh:39
static const int prLRU
Definition: XrdRmcData.hh:136
XrdSysXS_Type
Definition: XrdSysXSLock.hh:38
static int setAPR(aprParms &Dest, aprParms &Src, int pSize)
static const int prWait
Definition: XrdRmcData.hh:134