00001 #ifndef __CMS_BASEFS_H__
00002 #define __CMS_BASEFS_H__
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 <stdlib.h>
00034 #include <string.h>
00035
00036 #include "XrdCms/XrdCmsPList.hh"
00037 #include "XrdCms/XrdCmsRRData.hh"
00038 #include "XrdCms/XrdCmsTypes.hh"
00039 #include "XrdOuc/XrdOucHash.hh"
00040 #include "XrdSys/XrdSysPthread.hh"
00041
00042
00043
00044
00045
00046 class XrdCmsPInfo;
00047
00048 class XrdCmsBaseFR
00049 {
00050 public:
00051
00052 SMask_t Route;
00053 SMask_t RouteW;
00054 XrdCmsBaseFR *Next;
00055 char *Buff;
00056 char *Path;
00057 short PathLen;
00058 short PDirLen;
00059 kXR_unt32 Sid;
00060 kXR_char Mod;
00061
00062 XrdCmsBaseFR(XrdCmsRRData &Arg, XrdCmsPInfo &Who, int Dln)
00063 : Route(Who.rovec), RouteW(Who.rwvec), Next(0),
00064 PathLen(Arg.PathLen), PDirLen(Dln),
00065 Sid(Arg.Request.streamid),
00066 Mod(Arg.Request.modifier)
00067 {if (Arg.Buff)
00068 {Path=Arg.Path; Buff=Arg.Buff; Arg.Buff=0;}
00069 else Buff = Path = strdup(Arg.Path);
00070 }
00071
00072 XrdCmsBaseFR(XrdCmsRRData *aP, XrdCmsPInfo &Who, int Dln)
00073 : Route(Who.rovec), RouteW(Who.rwvec),
00074 Next(0), Buff(0), Path(aP->Path),
00075 PathLen(aP->PathLen), PDirLen(Dln),
00076 Sid(aP->Request.streamid),
00077 Mod(aP->Request.modifier)
00078 {}
00079
00080 ~XrdCmsBaseFR() {if (Buff) free(Buff); Buff = 0;}
00081 };
00082
00083
00084
00085
00086
00087 class XrdCmsBaseFS
00088 {
00089 public:
00090
00091 int dfsTries() {return dfsMaxTries;}
00092
00093
00094
00095
00096
00097
00098
00099 int Exists(XrdCmsRRData &Arg,XrdCmsPInfo &Who,int noLim=0);
00100
00101
00102
00103
00104
00105
00106
00107
00108 int Exists(char *Path, int fnPos, int UpAT=0);
00109
00110
00111
00112 static const int Cntrl = 0x0001;
00113 static const int DFSys = 0x0002;
00114 static const int Immed = 0x0004;
00115 static const int Servr = 0x0100;
00116
00117 void Init(int Opts, int DMlife, int DPLife);
00118
00119 inline int isDFS() {return dfsSys;}
00120
00121 inline int Limit() {return theQ.rLimit;}
00122
00123 void Limit(int rLim, int qMax);
00124
00125 inline int Local() {return lclStat;}
00126
00127 void Pacer();
00128
00129 void Runner();
00130
00131 static const int dfltDfsTries = 2;
00132 static const int dfltStgTries = 3;
00133
00134 void SetTries(bool xdfs, int tcnt)
00135 {if (xdfs) dfsMaxTries =
00136 (tcnt < 0 ? dfltDfsTries : tcnt);
00137 else stgMaxTries =
00138 (tcnt < 1 ? dfltStgTries : tcnt);
00139 }
00140
00141 void Start();
00142
00143 int stgTries() {return stgMaxTries;}
00144
00145 inline int Trim() {return preSel;}
00146
00147 inline int Traverse() {return Punt;}
00148
00149 XrdCmsBaseFS(void (*theCB)(XrdCmsBaseFR *, int))
00150 : cBack(theCB), dfsMaxTries(dfltDfsTries),
00151 stgMaxTries(dfltStgTries),
00152 dmLife(0), dpLife(0), lclStat(0), preSel(1),
00153 dfsSys(0), Server(0), Fixed(0), Punt(0) {}
00154 ~XrdCmsBaseFS() {}
00155
00156 private:
00157
00158 struct dMoP {int Present;};
00159
00160 int Bypass();
00161 int FStat( char *Path, int fnPos, int upat=0);
00162 int hasDir(char *Path, int fnPos);
00163 void Queue(XrdCmsRRData &Arg, XrdCmsPInfo &Who,
00164 int dln, int Frc=0);
00165 void Xeq(XrdCmsBaseFR *rP);
00166
00167 XrdSysMutex fsMutex;
00168 XrdOucHash<dMoP> fsDirMP;
00169 void (*cBack)(XrdCmsBaseFR *, int);
00170
00171 struct RequestQ
00172 {XrdSysMutex Mutex;
00173 XrdSysSemaphore pqAvail;
00174 XrdSysSemaphore rqAvail;
00175 XrdCmsBaseFR *pqFirst;
00176 XrdCmsBaseFR *pqLast;
00177 XrdCmsBaseFR *rqFirst;
00178 XrdCmsBaseFR *rqLast;
00179 int rLimit;
00180 int qHWM;
00181 int qMax;
00182 int qNum;
00183 int rLeft;
00184 int rAgain;
00185 RequestQ() : pqAvail(0), rqAvail(0),
00186 pqFirst(0), pqLast(0), rqFirst(0), rqLast(0),
00187 rLimit(0), qHWM(0), qMax(1), qNum(0),
00188 rLeft(0), rAgain(0) {}
00189 ~RequestQ() {}
00190 } theQ;
00191
00192 int dfsMaxTries;
00193 int stgMaxTries;
00194 int dmLife;
00195 int dpLife;
00196 char lclStat;
00197 char preSel;
00198 char dfsSys;
00199 char Server;
00200 char Fixed;
00201 char Punt;
00202 };
00203 namespace XrdCms
00204 {
00205 extern XrdCmsBaseFS baseFS;
00206 }
00207 #endif