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