XRootD
Loading...
Searching...
No Matches
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"
41
43{
44public:
45
46bool Detach(XrdOucCacheIOCD &iocd);
47
48long long FSize() {return (ioObj ? ioObj->FSize() : 0);}
49
50const char *Path() {return ioObj->Path();}
51
52void Preread();
53
54void Preread(aprParms &Parms);
55
56void Preread(long long Offs, int rLen, int Opts=0);
57
58int Read (char *Buffer, long long Offset, int Length);
59
60static int setAPR(aprParms &Dest, aprParms &Src, int pSize);
61
62int Sync() {return 0;} // We only support write-through for now
63
64int Trunc(long long Offset);
65
66int Write(char *Buffer, long long Offset, int Length);
67
69 long long vn, int opts);
70
71private:
72 ~XrdRmcData() {}
73void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0);
74int Read (XrdOucCacheStats &Now,
75 char *Buffer, long long Offs, int Length);
76
78
79// The following is for read/write support
80//
81class MrSw
82{
83public:
84inline void UnLock() {if (myLock) {myLock->UnLock(myUsage); myLock = 0;}}
85
86 MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage) : myUsage(usage)
87 {if ((myLock = lP)) lP->Lock(usage);}
88 ~MrSw() {if (myLock) myLock->UnLock(myUsage);}
89
90private:
91XrdSysXSLock *myLock;
92XrdSysXS_Type myUsage;
93};
94
95// Statics per connection
96//
97XrdOucCacheStats Statistics;
98
99// The following supports MRSW serialization
100//
101XrdSysXSLock rwLock;
102XrdSysXSLock *pPLock; // 0 if no preread lock required
103XrdSysXSLock *rPLock; // 0 if no read lock required
104XrdSysXSLock *wPLock; // 0 if no write lock required
105XrdSysXS_Type pPLopt;
106XrdSysXS_Type rPLopt;
107
108XrdSysMutex DMutex;
109XrdRmcReal *Cache;
110XrdOucCacheIO *ioObj;
111long long VNum;
112long long SegSize;
113long long OffMask;
114long long SegShft;
115int maxCache;
116char isFIS;
117char isRW;
118char Debug;
119
120static const int okRW = 1;
121static const int xqRW = 2;
122
123// Preread Control Area
124//
125XrdRmcReal::prTask prReq;
126XrdSysSemaphore *prStop;
127
128long long prNSS; // Next Sequential Segment for maxi prereads
129
130static const int prRRMax= 5;
131long long prRR[prRRMax]; // Recent reads
132int prRRNow; // Pointer to next entry to use
133
134static const int prMax = 8;
135static const int prRun = 1; // Status in prActive (running)
136static const int prWait = 2; // Status in prActive (waiting)
137
138static const int prLRU = 1; // Status in prOpt (set LRU)
139static const int prSUSE = 2; // Status in prOpt (set Single Use)
140static const int prSKIP = 3; // Status in prOpt (skip entry)
141
142aprParms Apr;
143long long prCalc;
144long long prBeg[prMax];
145long long prEnd[prMax];
146int prNext;
147int prFree;
148int prPerf;
149char prOpt[prMax];
150char prOK;
151char prActive;
152char prAuto;
153};
154#endif
void usage()
struct myOpts opts
XrdSysXS_Type
virtual int Read(char *buff, long long offs, int rlen)=0
XrdOucCacheIO()
Construct and Destructor.
int Read(char *Buffer, long long Offset, int Length)
void Preread()
int Trunc(long long Offset)
XrdRmcData(XrdRmcReal *cP, XrdOucCacheIO *ioP, long long vn, int opts)
Definition XrdRmcData.cc:42
long long FSize()
Definition XrdRmcData.hh:48
int Write(char *Buffer, long long Offset, int Length)
const char * Path()
Definition XrdRmcData.hh:50
bool Detach(XrdOucCacheIOCD &iocd)
Definition XrdRmcData.cc:97
static int setAPR(aprParms &Dest, aprParms &Src, int pSize)
void Lock(const XrdSysXS_Type usage)