00001 #ifndef __XRDRMCREAL_HH__
00002 #define __XRDRMCREAL_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "XrdRmc/XrdRmc.hh"
00034 #include "XrdRmc/XrdRmcSlot.hh"
00035 #include "XrdSys/XrdSysPthread.hh"
00036
00037
00038
00039 class XrdRmcReal : public XrdOucCache
00040 {
00041 friend class XrdRmcData;
00042 public:
00043
00044 XrdOucCacheIO *Attach(XrdOucCacheIO *ioP, int Options=0);
00045
00046 XrdRmcReal(int &rc,
00047 XrdRmc::Parms &Parms,
00048 XrdOucCacheIO::aprParms *aprP=0);
00049
00050 ~XrdRmcReal();
00051
00052 void PreRead();
00053
00054 private:
00055
00056 void eMsg(const char *Path, const char *What, long long xOff,
00057 int xLen, int ec);
00058 int Detach(XrdOucCacheIO *ioP);
00059 char *Get(XrdOucCacheIO *ioP, long long lAddr, int &rGot, int &bIO);
00060
00061 int ioAdd(XrdOucCacheIO *KeyVal, int &iNum);
00062 int ioDel(XrdOucCacheIO *KeyVal, int &iNum);
00063
00064 inline
00065 int ioEnt(XrdOucCacheIO *kVal)
00066 {union {short sV[4]; XrdOucCacheIO *pV;} Key = {{0,0,0,0}};
00067 Key.pV = kVal;
00068 return ((Key.sV[0]^Key.sV[1]^Key.sV[2]^Key.sV[3])&0x7fff)%hMax;
00069 }
00070 inline
00071 int ioLookup(int &pip, int hip, void *kval)
00072 {pip = 0;
00073 while(hip && kval != Slots[hip].Key)
00074 {pip = hip; hip = Slots[hip].HLink;}
00075 return hip;
00076 }
00077
00078 int Ref(char *Addr, int rAmt, int sFlags=0);
00079 void Trunc(XrdOucCacheIO *ioP, long long lAddr);
00080 void Upd(char *Addr, int wAmt, int wOff);
00081
00082 static const long long Shift = 48;
00083 static const long long Strip = 0x00000000ffffffffLL;
00084 static const long long MaxFO = 0x000007ffffffffffLL;
00085
00086 XrdOucCacheIO::aprParms aprDefault;
00087
00088 XrdSysMutex CMutex;
00089 XrdRmcSlot *Slots;
00090 int *Slash;
00091 char *Base;
00092 long long HNum;
00093 long long SegCnt;
00094 long long SegSize;
00095 long long OffMask;
00096 long long SegShft;
00097 int SegFull;
00098 int maxCache;
00099 int maxFiles;
00100 int Options;
00101
00102
00103
00104 int *hTab;
00105 int hMax;
00106 int sFree;
00107 int sBeg;
00108 int sEnd;
00109
00110
00111
00112 char Dbg;
00113 char Lgs;
00114
00115
00116
00117 XrdSysSemaphore *AZero;
00118 int Attached;
00119
00120
00121
00122 struct prTask
00123 {prTask *Next;
00124 XrdRmcData *Data;
00125 };
00126 void PreRead(XrdRmcReal::prTask *prReq);
00127 prTask *prFirst;
00128 prTask *prLast;
00129 XrdSysMutex prMutex;
00130 XrdSysSemaphore prReady;
00131 XrdSysSemaphore *prStop;
00132 int prNum;
00133 };
00134 #endif