xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XrdOucCacheData.hh
Go to the documentation of this file.
1 #ifndef __XRDOUCCACHEDATA_HH__
2 #define __XRDOUCCACHEDATA_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d O u c C a c h e D a t a . h h */
6 /* */
7 /* (c) 2011 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 XrdOucCacheData object defines a remanufactured XrdOucCacheIO object and
34  is used to front a XrdOucCacheIO object with an XrdOucCacheReal object.
35 */
36 
37 #include "XrdOuc/XrdOucCache.hh"
39 #include "XrdSys/XrdSysPthread.hh"
40 #include "XrdSys/XrdSysXSLock.hh"
41 
42 /******************************************************************************/
43 /* C l a s s X r d O u c C a c h e D a t a */
44 /******************************************************************************/
45 
47 {
48 public:
49 
50 XrdOucCacheIO *Base() {return ioObj;}
51 
53 
54 long long FSize() {return (ioObj ? ioObj->FSize() : 0);}
55 
56 const char *Path() {return ioObj->Path();}
57 
58 void Preread();
59 
60 void Preread(aprParms &Parms);
61 
62 void Preread(long long Offs, int rLen, int Opts=0);
63 
64 int Read (char *Buffer, long long Offset, int Length);
65 
66 static int setAPR(aprParms &Dest, aprParms &Src, int pSize);
67 
68 int Sync() {return 0;} // We only support write-through for now
69 
70 int Trunc(long long Offset);
71 
72 int Write(char *Buffer, long long Offset, int Length);
73 
75  long long vn, int opts);
76 
77 private:
79 void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0);
80 int Read (XrdOucCacheStats &Now,
81  char *Buffer, long long Offs, int Length);
82 
83 // The following is for read/write support
84 //
85 class MrSw
86 {
87 public:
88 inline void UnLock() {if (myLock) {myLock->UnLock(myUsage); myLock = 0;}}
89 
90  MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage) : myUsage(usage)
91  {if ((myLock = lP)) lP->Lock(usage);}
93 
94 private:
97 };
98 
99 // The following supports MRSW serialization
100 //
102 XrdSysXSLock *pPLock; // 0 if no preread lock required
103 XrdSysXSLock *rPLock; // 0 if no read lock required
104 XrdSysXSLock *wPLock; // 0 if no write lock required
107 
111 long long VNum;
112 long long SegSize;
113 long long OffMask;
114 long long SegShft;
116 char isFIS;
117 char isRW;
118 char isADB;
119 char Debug;
120 
121 static const int okRW = 1;
122 static const int xqRW = 2;
123 
124 // Preread Control Area
125 //
128 
129 long long prNSS; // Next Sequential Segment for maxi prereads
130 
131 static const int prRRMax= 5;
132 long long prRR[prRRMax]; // Recent reads
133 int prRRNow; // Pointer to next entry to use
134 
135 static const int prMax = 8;
136 static const int prRun = 1; // Status in prActive (running)
137 static const int prWait = 2; // Status in prActive (waiting)
138 
139 static const int prLRU = 1; // Status in prOpt (set LRU)
140 static const int prSUSE = 2; // Status in prOpt (set Single Use)
141 static const int prSKIP = 3; // Status in prOpt (skip entry)
142 
143 aprParms Apr;
144 long long prCalc;
145 long long prBeg[prMax];
146 long long prEnd[prMax];
147 int prNext;
148 int prFree;
149 int prPerf;
150 char prOpt[prMax];
151 char prOK;
152 char prActive;
153 char prAuto;
154 };
155 #endif
static const int xqRW
Definition: XrdOucCacheData.hh:122
static const int prSKIP
Definition: XrdOucCacheData.hh:141
char prOK
Definition: XrdOucCacheData.hh:151
char Debug
Definition: XrdOucCacheData.hh:119
static const int prLRU
Definition: XrdOucCacheData.hh:139
char isFIS
Definition: XrdOucCacheData.hh:116
XrdSysXSLock * myLock
Definition: XrdOucCacheData.hh:95
Definition: XrdOucCacheData.hh:85
char prActive
Definition: XrdOucCacheData.hh:152
int Write(char *Buffer, long long Offset, int Length)
XrdOucCacheData(XrdOucCacheReal *cP, XrdOucCacheIO *ioP, long long vn, int opts)
int Trunc(long long Offset)
int prPerf
Definition: XrdOucCacheData.hh:149
static const int prWait
Definition: XrdOucCacheData.hh:137
Definition: XrdOucCacheReal.hh:127
void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0)
Definition: XrdOucCacheData.hh:46
Definition: XrdOucCache.hh:102
int prRRNow
Definition: XrdOucCacheData.hh:133
XrdOucCacheIO * Base()
Definition: XrdOucCacheData.hh:50
Definition: XrdSysXSLock.hh:44
XrdSysSemaphore * prStop
Definition: XrdOucCacheData.hh:127
XrdSysXSLock * pPLock
Definition: XrdOucCacheData.hh:102
~XrdOucCacheData()
Definition: XrdOucCacheData.hh:78
long long prEnd[prMax]
Definition: XrdOucCacheData.hh:146
XrdOucCacheIO * Detach()
static int setAPR(aprParms &Dest, aprParms &Src, int pSize)
int prNext
Definition: XrdOucCacheData.hh:147
static const int prSUSE
Definition: XrdOucCacheData.hh:140
XrdOucCacheReal::prTask prReq
Definition: XrdOucCacheData.hh:126
long long prNSS
Definition: XrdOucCacheData.hh:129
XrdSysXSLock * rPLock
Definition: XrdOucCacheData.hh:103
long long OffMask
Definition: XrdOucCacheData.hh:113
Definition: XrdSysPthread.hh:165
char prOpt[prMax]
Definition: XrdOucCacheData.hh:150
char isRW
Definition: XrdOucCacheData.hh:117
void UnLock(const XrdSysXS_Type usage=xs_None)
virtual const char * Path()=0
const char * Path()
Definition: XrdOucCacheData.hh:56
int Sync()
Definition: XrdOucCacheData.hh:68
XrdSysXSLock rwLock
Definition: XrdOucCacheData.hh:101
Definition: XrdSysPthread.hh:403
long long prRR[prRRMax]
Definition: XrdOucCacheData.hh:132
Definition: XrdOucCacheReal.hh:39
long long SegShft
Definition: XrdOucCacheData.hh:114
XrdSysXS_Type myUsage
Definition: XrdOucCacheData.hh:96
static const int okRW
Definition: XrdOucCacheData.hh:121
~MrSw()
Definition: XrdOucCacheData.hh:92
int prFree
Definition: XrdOucCacheData.hh:148
long long SegSize
Definition: XrdOucCacheData.hh:112
static const int prMax
Definition: XrdOucCacheData.hh:135
char prAuto
Definition: XrdOucCacheData.hh:153
static const int prRRMax
Definition: XrdOucCacheData.hh:131
static const int prRun
Definition: XrdOucCacheData.hh:136
void Lock(const XrdSysXS_Type usage)
void UnLock()
Definition: XrdOucCacheData.hh:88
XrdSysXS_Type rPLopt
Definition: XrdOucCacheData.hh:106
long long prCalc
Definition: XrdOucCacheData.hh:144
aprParms Apr
Definition: XrdOucCacheData.hh:143
long long prBeg[prMax]
Definition: XrdOucCacheData.hh:145
long long VNum
Definition: XrdOucCacheData.hh:111
XrdOucCacheIO * ioObj
Definition: XrdOucCacheData.hh:110
int Read(char *Buffer, long long Offset, int Length)
XrdOucCacheReal * Cache
Definition: XrdOucCacheData.hh:109
Definition: XrdOucCacheStats.hh:43
virtual long long FSize()=0
MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage)
Definition: XrdOucCacheData.hh:90
long long FSize()
Definition: XrdOucCacheData.hh:54
XrdSysMutex DMutex
Definition: XrdOucCacheData.hh:108
int maxCache
Definition: XrdOucCacheData.hh:115
XrdSysXS_Type pPLopt
Definition: XrdOucCacheData.hh:105
char isADB
Definition: XrdOucCacheData.hh:118
XrdSysXS_Type
Definition: XrdSysXSLock.hh:38
XrdSysXSLock * wPLock
Definition: XrdOucCacheData.hh:104