|
xrootd
|
00001 #ifndef __XRDOUCCACHEDATA_HH__ 00002 #define __XRDOUCCACHEDATA_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O u c C a c h e D a t a . h h */ 00006 /* */ 00007 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 /* The XrdOucCacheData object defines a remanufactured XrdOucCacheIO object and 00034 is used to front a XrdOucCacheIO object with an XrdOucCacheReal object. 00035 */ 00036 00037 #include "XrdOuc/XrdOucCache.hh" 00038 #include "XrdOuc/XrdOucCacheReal.hh" 00039 #include "XrdSys/XrdSysPthread.hh" 00040 #include "XrdSys/XrdSysXSLock.hh" 00041 00042 /******************************************************************************/ 00043 /* C l a s s X r d O u c C a c h e D a t a */ 00044 /******************************************************************************/ 00045 00046 class XrdOucCacheData : public XrdOucCacheIO 00047 { 00048 public: 00049 00050 XrdOucCacheIO *Base() {return ioObj;} 00051 00052 XrdOucCacheIO *Detach(); 00053 00054 long long FSize() {return (ioObj ? ioObj->FSize() : 0);} 00055 00056 const char *Path() {return ioObj->Path();} 00057 00058 void Preread(); 00059 00060 void Preread(aprParms &Parms); 00061 00062 void Preread(long long Offs, int rLen, int Opts=0); 00063 00064 int Read (char *Buffer, long long Offset, int Length); 00065 00066 static int setAPR(aprParms &Dest, aprParms &Src, int pSize); 00067 00068 int Sync() {return 0;} // We only support write-through for now 00069 00070 int Trunc(long long Offset); 00071 00072 int Write(char *Buffer, long long Offset, int Length); 00073 00074 XrdOucCacheData(XrdOucCacheReal *cP, XrdOucCacheIO *ioP, 00075 long long vn, int opts); 00076 00077 private: 00078 ~XrdOucCacheData() {} 00079 void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0); 00080 int Read (XrdOucCacheStats &Now, 00081 char *Buffer, long long Offs, int Length); 00082 00083 // The following is for read/write support 00084 // 00085 class MrSw 00086 { 00087 public: 00088 inline void UnLock() {if (myLock) {myLock->UnLock(myUsage); myLock = 0;}} 00089 00090 MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage) : myUsage(usage) 00091 {if ((myLock = lP)) lP->Lock(usage);} 00092 ~MrSw() {if (myLock) myLock->UnLock(myUsage);} 00093 00094 private: 00095 XrdSysXSLock *myLock; 00096 XrdSysXS_Type myUsage; 00097 }; 00098 00099 // The following supports MRSW serialization 00100 // 00101 XrdSysXSLock rwLock; 00102 XrdSysXSLock *pPLock; // 0 if no preread lock required 00103 XrdSysXSLock *rPLock; // 0 if no read lock required 00104 XrdSysXSLock *wPLock; // 0 if no write lock required 00105 XrdSysXS_Type pPLopt; 00106 XrdSysXS_Type rPLopt; 00107 00108 XrdSysMutex DMutex; 00109 XrdOucCacheReal *Cache; 00110 XrdOucCacheIO *ioObj; 00111 long long VNum; 00112 long long SegSize; 00113 long long OffMask; 00114 long long SegShft; 00115 int maxCache; 00116 char isFIS; 00117 char isRW; 00118 char isADB; 00119 char Debug; 00120 00121 static const int okRW = 1; 00122 static const int xqRW = 2; 00123 00124 // Preread Control Area 00125 // 00126 XrdOucCacheReal::prTask prReq; 00127 XrdSysSemaphore *prStop; 00128 00129 long long prNSS; // Next Sequential Segment for maxi prereads 00130 00131 static const int prRRMax= 5; 00132 long long prRR[prRRMax]; // Recent reads 00133 int prRRNow; // Pointer to next entry to use 00134 00135 static const int prMax = 8; 00136 static const int prRun = 1; // Status in prActive (running) 00137 static const int prWait = 2; // Status in prActive (waiting) 00138 00139 static const int prLRU = 1; // Status in prOpt (set LRU) 00140 static const int prSUSE = 2; // Status in prOpt (set Single Use) 00141 static const int prSKIP = 3; // Status in prOpt (skip entry) 00142 00143 aprParms Apr; 00144 long long prCalc; 00145 long long prBeg[prMax]; 00146 long long prEnd[prMax]; 00147 int prNext; 00148 int prFree; 00149 int prPerf; 00150 char prOpt[prMax]; 00151 char prOK; 00152 char prActive; 00153 char prAuto; 00154 }; 00155 #endif
1.7.6.1