|
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 00013 /* The XrdOucCacheData object defines a remanufactured XrdOucCacheIO object and 00014 is used to front a XrdOucCacheIO object with an XrdOucCacheReal object. 00015 */ 00016 00017 #include "XrdOuc/XrdOucCache.hh" 00018 #include "XrdOuc/XrdOucCacheReal.hh" 00019 #include "XrdSys/XrdSysPthread.hh" 00020 #include "XrdSys/XrdSysXSLock.hh" 00021 00022 /******************************************************************************/ 00023 /* C l a s s X r d O u c C a c h e D a t a */ 00024 /******************************************************************************/ 00025 00026 class XrdOucCacheData : public XrdOucCacheIO 00027 { 00028 public: 00029 00030 XrdOucCacheIO *Base() {return ioObj;} 00031 00032 XrdOucCacheIO *Detach(); 00033 00034 const char *Path() {return ioObj->Path();} 00035 00036 void Preread(); 00037 00038 void Preread(aprParms &Parms); 00039 00040 void Preread(long long Offs, int rLen, int Opts=0); 00041 00042 int Read (char *Buffer, long long Offset, int Length); 00043 00044 static int setAPR(aprParms &Dest, aprParms &Src, int pSize); 00045 00046 int Sync() {return 0;} // We only support write-through for now 00047 00048 int Trunc(long long Offset); 00049 00050 int Write(char *Buffer, long long Offset, int Length); 00051 00052 XrdOucCacheData(XrdOucCacheReal *cP, XrdOucCacheIO *ioP, 00053 long long vn, int opts); 00054 00055 private: 00056 ~XrdOucCacheData() {} 00057 void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0); 00058 int Read (XrdOucCacheStats &Now, 00059 char *Buffer, long long Offs, int Length); 00060 00061 // The following is for read/write support 00062 // 00063 class MrSw 00064 { 00065 public: 00066 inline void UnLock() {if (myLock) {myLock->UnLock(myUsage); myLock = 0;}} 00067 00068 MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage) : myUsage(usage) 00069 {if ((myLock = lP)) lP->Lock(usage);} 00070 ~MrSw() {if (myLock) myLock->UnLock(myUsage);} 00071 00072 private: 00073 XrdSysXSLock *myLock; 00074 XrdSysXS_Type myUsage; 00075 }; 00076 00077 // The following supports MRSW serialization 00078 // 00079 XrdSysXSLock rwLock; 00080 XrdSysXSLock *pPLock; // 0 if no preread lock required 00081 XrdSysXSLock *rPLock; // 0 if no read lock required 00082 XrdSysXSLock *wPLock; // 0 if no write lock required 00083 XrdSysXS_Type pPLopt; 00084 XrdSysXS_Type rPLopt; 00085 00086 XrdSysMutex DMutex; 00087 XrdOucCacheReal *Cache; 00088 XrdOucCacheIO *ioObj; 00089 long long VNum; 00090 long long SegSize; 00091 long long OffMask; 00092 long long SegShft; 00093 int maxCache; 00094 char isFIS; 00095 char isRW; 00096 char isADB; 00097 char Debug; 00098 00099 static const int okRW = 1; 00100 static const int xqRW = 2; 00101 00102 // Preread Control Area 00103 // 00104 XrdOucCacheReal::prTask prReq; 00105 XrdSysSemaphore *prStop; 00106 00107 long long prNSS; // Next Sequential Segment for maxi prereads 00108 00109 static const int prRRMax= 5; 00110 long long prRR[prRRMax]; // Recent reads 00111 int prRRNow; // Pointer to next entry to use 00112 00113 static const int prMax = 8; 00114 static const int prRun = 1; // Status in prActive (running) 00115 static const int prWait = 2; // Status in prActive (waiting) 00116 00117 static const int prLRU = 1; // Status in prOpt (set LRU) 00118 static const int prSUSE = 2; // Status in prOpt (set Single Use) 00119 static const int prSKIP = 3; // Status in prOpt (skip entry) 00120 00121 aprParms Apr; 00122 long long prCalc; 00123 long long prBeg[prMax]; 00124 long long prEnd[prMax]; 00125 int prNext; 00126 int prFree; 00127 int prPerf; 00128 char prOpt[prMax]; 00129 char prOK; 00130 char prActive; 00131 char prAuto; 00132 }; 00133 #endif
1.7.5