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