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