00001 #ifndef _XRDOSS_API_H
00002 #define _XRDOSS_API_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 <sys/types.h>
00034 #include <errno.h>
00035 #include "XrdSys/XrdSysHeaders.hh"
00036
00037 #include "XrdOss/XrdOss.hh"
00038 #include "XrdOss/XrdOssConfig.hh"
00039 #include "XrdOss/XrdOssError.hh"
00040 #include "XrdOss/XrdOssStatInfo.hh"
00041 #include "XrdOuc/XrdOucExport.hh"
00042 #include "XrdOuc/XrdOucPList.hh"
00043 #include "XrdOuc/XrdOucStream.hh"
00044 #include "XrdSys/XrdSysError.hh"
00045 #include "XrdSys/XrdSysPthread.hh"
00046
00047
00048
00049
00050
00051 class XrdOssDir : public XrdOssDF
00052 {
00053 public:
00054 int Close(long long *retsz=0);
00055 int Opendir(const char *, XrdOucEnv &);
00056 int Readdir(char *buff, int blen);
00057 int StatRet(struct stat *buff);
00058
00059
00060 XrdOssDir(const char *tid) : lclfd(0), mssfd(0), Stat(0), tident(tid),
00061 pflags(0), ateof(0), isopen(0), dirFD(0)
00062 {}
00063 ~XrdOssDir() {if (isopen > 0) Close(); isopen = 0;}
00064 private:
00065 DIR *lclfd;
00066 void *mssfd;
00067 struct stat *Stat;
00068 const char *tident;
00069 unsigned long long pflags;
00070 int ateof;
00071 int isopen;
00072 int dirFD;
00073 };
00074
00075
00076
00077
00078
00079 class oocx_CXFile;
00080 class XrdSfsAio;
00081 class XrdOssCache_FS;
00082 class XrdOssMioFile;
00083
00084 class XrdOssFile : public XrdOssDF
00085 {
00086 public:
00087
00088
00089
00090
00091 virtual int Close(long long *retsz=0);
00092 virtual int Open(const char *, int, mode_t, XrdOucEnv &);
00093
00094 int Fchmod(mode_t mode);
00095 int Fstat(struct stat *);
00096 int Fsync();
00097 int Fsync(XrdSfsAio *aiop);
00098 int Ftruncate(unsigned long long);
00099 int getFD() {return fd;}
00100 off_t getMmap(void **addr);
00101 int isCompressed(char *cxidp=0);
00102 ssize_t Read( off_t, size_t);
00103 ssize_t Read( void *, off_t, size_t);
00104 int Read(XrdSfsAio *aiop);
00105 ssize_t ReadV(XrdOucIOVec *readV, int);
00106 ssize_t ReadRaw( void *, off_t, size_t);
00107 ssize_t Write(const void *, off_t, size_t);
00108 int Write(XrdSfsAio *aiop);
00109
00110
00111 XrdOssFile(const char *tid)
00112 {cxobj = 0; rawio = 0; cxpgsz = 0; cxid[0] = '\0';
00113 mmFile = 0; tident = tid;
00114 }
00115
00116 virtual ~XrdOssFile() {if (fd >= 0) Close();}
00117
00118 private:
00119 int Open_ufs(const char *, int, int, unsigned long long);
00120
00121 static int AioFailure;
00122 oocx_CXFile *cxobj;
00123 XrdOssCache_FS *cacheP;
00124 XrdOssMioFile *mmFile;
00125 const char *tident;
00126 long long FSize;
00127 int rawio;
00128 int cxpgsz;
00129 char cxid[4];
00130 };
00131
00132
00133
00134
00135
00136 class XrdFrcProxy;
00137 class XrdOssCache_Group;
00138 class XrdOssCache_Space;
00139 class XrdOssCreateInfo;
00140 class XrdOucMsubs;
00141 class XrdOucName2Name;
00142 class XrdOucProg;
00143 class XrdOssSpace;
00144 class XrdOssStage_Req;
00145
00146 struct XrdVersionInfo;
00147
00148 class XrdOssSys : public XrdOss
00149 {
00150 public:
00151 virtual XrdOssDF *newDir(const char *tident)
00152 {return (XrdOssDF *)new XrdOssDir(tident);}
00153 virtual XrdOssDF *newFile(const char *tident)
00154 {return (XrdOssDF *)new XrdOssFile(tident);}
00155
00156 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
00157 int Configure(const char *, XrdSysError &, XrdOucEnv *envP);
00158 void Config_Display(XrdSysError &);
00159 virtual
00160 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
00161 int GenLocalPath(const char *, char *);
00162 int GenRemotePath(const char *, char *);
00163 int Init(XrdSysLogger *, const char *, XrdOucEnv *envP);
00164 int Init(XrdSysLogger *lP, const char *cP) {return Init(lP, cP, 0);}
00165 int IsRemote(const char *path)
00166 {return (RPList.Find(path) & XRDEXP_REMOTE) != 0;}
00167 int Lfn2Pfn(const char *Path, char *buff, int blen);
00168 const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
00169 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
00170 int Mkpath(const char *, mode_t mode);
00171 unsigned long long PathOpts(const char *path) {return RPList.Find(path);}
00172 int Reloc(const char *tident, const char *path,
00173 const char *cgName, const char *anchor=0);
00174 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
00175 int Rename(const char *, const char *,
00176 XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
00177 virtual
00178 int Stage(const char *, const char *, XrdOucEnv &, int, mode_t, unsigned long long );
00179 void *Stage_In(void *carg);
00180 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *Env=0);
00181 int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *Env=0);
00182 int StatFS(const char *path, unsigned long long &Opt,
00183 long long &fSize, long long &fSpace);
00184 int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen);
00185 int StatPF(const char *, struct stat *);
00186 int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0);
00187 int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *Env=0);
00188 int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *Env=0);
00189 int Truncate(const char *, unsigned long long Size, XrdOucEnv *eP=0);
00190 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
00191
00192 int Stats(char *bp, int bl);
00193
00194 static int AioInit();
00195 static int AioAllOk;
00196
00197 static int runOld;
00198
00199 static char tryMmap;
00200 static char chkMmap;
00201
00202 int MSS_Closedir(void *);
00203 int MSS_Create(const char *path, mode_t, XrdOucEnv &);
00204 void *MSS_Opendir(const char *, int &rc);
00205 int MSS_Readdir(void *fd, char *buff, int blen);
00206 int MSS_Remdir(const char *, const char *) {return -ENOTSUP;}
00207 int MSS_Rename(const char *, const char *);
00208 int MSS_Stat(const char *, struct stat *buff=0);
00209 int MSS_Unlink(const char *);
00210
00211 static const int MaxArgs = 15;
00212
00213 char *ConfigFN;
00214 char *LocalRoot;
00215 char *RemoteRoot;
00216 int MaxTwiddle;
00217 int StageRealTime;
00218 int StageAsync;
00219 int StageCreate;
00220 int StageFormat;
00221 char *StageCmd;
00222 char *StageMsg;
00223 XrdOucMsubs *StageSnd;
00224 XrdFrcProxy *StageFrm;
00225
00226 char *StageEvents;
00227 int StageEvSize;
00228 int StageActLen;
00229 char *StageAction;
00230
00231 char *StageArg[MaxArgs];
00232 int StageAln[MaxArgs];
00233 int StageAnum;
00234 char *RSSCmd;
00235 int isMSSC;
00236 int RSSTout;
00237 long long MaxSize;
00238 int FDFence;
00239 int FDLimit;
00240 unsigned long long DirFlags;
00241 int Trace;
00242 int Solitary;
00243 int OptFlags;
00244
00245 XrdOucPListAnchor SPList;
00246 #define spAssign 1
00247
00248 char *N2N_Lib;
00249 char *N2N_Parms;
00250 XrdOucName2Name *lcl_N2N;
00251 XrdOucName2Name *rmt_N2N;
00252 XrdOucName2Name *the_N2N;
00253 XrdOucPListAnchor RPList;
00254 OssDPath *DPList;
00255 int lenDP;
00256 short numDP;
00257 short numCG;
00258
00259 char *STT_Lib;
00260 char *STT_Parms;
00261 union {
00262 XrdOssStatInfo_t STT_Func;
00263 XrdOssStatInfo2_t STT_Fund;
00264 };
00265 int STT_PreOp;
00266 char STT_DoN2N;
00267 char STT_V2;
00268 char STT_DoARE;
00269
00270 long long prPBits;
00271 long long prPMask;
00272 int prPSize;
00273 int prBytes;
00274 int prActive;
00275 short prDepth;
00276 short prQSize;
00277
00278 XrdVersionInfo *myVersion;
00279
00280 XrdOssSys();
00281 virtual ~XrdOssSys() {}
00282
00283 protected:
00284
00285
00286 long long minalloc;
00287 int ovhalloc;
00288 int fuzalloc;
00289 int cscanint;
00290 int xfrspeed;
00291 int xfrovhd;
00292 int xfrhold;
00293 int xfrkeep;
00294 int xfrthreads;
00295 int xfrtcount;
00296 long long pndbytes;
00297 long long stgbytes;
00298 long long totbytes;
00299 int totreqs;
00300 int badreqs;
00301
00302 XrdOucProg *StageProg;
00303 XrdOucProg *RSSProg;
00304
00305 char *UDir;
00306 char *QFile;
00307 char *xfrFdir;
00308 int xfrFdln;
00309
00310 int Alloc_Cache(XrdOssCreateInfo &, XrdOucEnv &);
00311 int Alloc_Local(XrdOssCreateInfo &, XrdOucEnv &);
00312 int BreakLink(const char *local_path, struct stat &statbuff);
00313 int CalcTime();
00314 int CalcTime(XrdOssStage_Req *req);
00315 int SetFattr(XrdOssCreateInfo &crInfo, int datfd, time_t mtime);
00316 void doScrub();
00317 int Find(XrdOssStage_Req *req, void *carg);
00318 int getCname(const char *path, struct stat *sbuff, char *cgbuff);
00319 int getStats(char *buff, int blen);
00320 int GetFile(XrdOssStage_Req *req);
00321 int getID(const char *, XrdOucEnv &, char *, int);
00322 time_t HasFile(const char *fn, const char *sfx, time_t *mTime=0);
00323 int Stage_QT(const char *, const char *, XrdOucEnv &, int, mode_t);
00324 int Stage_RT(const char *, const char *, XrdOucEnv &, unsigned long long);
00325
00326
00327
00328 void ConfigMio(XrdSysError &Eroute);
00329 int ConfigN2N(XrdSysError &Eroute, XrdOucEnv *envP);
00330 int ConfigProc(XrdSysError &Eroute);
00331 void ConfigSpace(XrdSysError &Eroute);
00332 void ConfigSpace(const char *Lfn);
00333 void ConfigSpath(XrdSysError &Eroute, const char *Pn,
00334 unsigned long long &Fv, int noMSS);
00335 int ConfigStage(XrdSysError &Eroute);
00336 int ConfigStageC(XrdSysError &Eroute);
00337 int ConfigStatLib(XrdSysError &Eroute, XrdOucEnv *envP);
00338 void ConfigStats(XrdSysError &Eroute);
00339 void ConfigStats(dev_t Devnum, char *lP);
00340 int ConfigXeq(char *, XrdOucStream &, XrdSysError &);
00341 void List_Path(const char *, const char *, unsigned long long, XrdSysError &);
00342 int xalloc(XrdOucStream &Config, XrdSysError &Eroute);
00343 int xcache(XrdOucStream &Config, XrdSysError &Eroute);
00344 int xcachescan(XrdOucStream &Config, XrdSysError &Eroute);
00345 int xdefault(XrdOucStream &Config, XrdSysError &Eroute);
00346 int xfdlimit(XrdOucStream &Config, XrdSysError &Eroute);
00347 int xmaxsz(XrdOucStream &Config, XrdSysError &Eroute);
00348 int xmemf(XrdOucStream &Config, XrdSysError &Eroute);
00349 int xnml(XrdOucStream &Config, XrdSysError &Eroute);
00350 int xpath(XrdOucStream &Config, XrdSysError &Eroute);
00351 int xprerd(XrdOucStream &Config, XrdSysError &Eroute);
00352 int xspace(XrdOucStream &Config, XrdSysError &Eroute, int *isCD=0);
00353 int xspace(XrdOucStream &Config, XrdSysError &Eroute,
00354 const char *grp, bool isAsgn);
00355 int xspaceBuild(char *grp, char *fn, int isxa, XrdSysError &Eroute);
00356 int xstg(XrdOucStream &Config, XrdSysError &Eroute);
00357 int xstl(XrdOucStream &Config, XrdSysError &Eroute);
00358 int xusage(XrdOucStream &Config, XrdSysError &Eroute);
00359 int xtrace(XrdOucStream &Config, XrdSysError &Eroute);
00360 int xxfr(XrdOucStream &Config, XrdSysError &Eroute);
00361
00362
00363
00364 int tranmode(char *);
00365 int MSS_Xeq(XrdOucStream **xfd, int okerr,
00366 const char *cmd, const char *arg1=0, const char *arg2=0);
00367
00368
00369
00370 int RenameLink(char *old_path, char *new_path);
00371 int RenameLink2(int Llen, char *oLnk, char *old_path,
00372 char *nLnk, char *new_path);
00373 int RenameLink3(char *cPath, char *old_path, char *new_path);
00374 };
00375
00376
00377
00378
00379
00380
00381
00382 #define Check_RO(act, flags, path, opname) \
00383 XRDEXP_REMOTE & (flags = PathOpts(path)); \
00384 if (flags & XRDEXP_NOTRW) \
00385 return OssEroute.Emsg(#act, -XRDOSS_E8005, opname, path)
00386
00387 #define Check_RW(act, path, opname) \
00388 if (PathOpts(path) & XRDEXP_NOTRW) \
00389 return OssEroute.Emsg(#act, -XRDOSS_E8005, opname, path)
00390 #endif