• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

XrdOssApi.hh

Go to the documentation of this file.
00001 #ifndef _XRDOSS_API_H
00002 #define _XRDOSS_API_H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X r d O s s A p i . h h                           */
00006 /*                                                                            */
00007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdOssApi.hh,v 1.46 2010/02/25 10:41:52 abh Exp $
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 /*                              o o s s _ D i r                               */
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         // Constructor and destructor
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 /*                             o o s s _ F i l e                              */
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 // The following two are virtual functions to allow for upcasting derivations
00066 // of this implementation
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         // Constructor and destructor
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 /*                              o o s s _ S y s                               */
00110 /******************************************************************************/
00111   
00112 class XrdOssCache_Group;
00113 class XrdOssCache_Space;
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);  // In Unlink()
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, int &Opt, long long &fSize, long long &fSpace);
00152 int       StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen);
00153 int       StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0);
00154 int       StatXA(const char *path, char *buff, int &blen);
00155 int       StatXP(const char *path, unsigned long long &attr);
00156 int       Truncate(const char *, unsigned long long Size);
00157 int       Unlink(const char *, int Opts=0);
00158 
00159 int       Stats(char *bp, int bl);
00160 
00161 static int   AioInit();
00162 static int   AioAllOk;
00163 
00164 static char  tryMmap;           // Memory mapped files enabled
00165 static char  chkMmap;           // Memory mapped files are selective
00166    
00167 int       MSS_Closedir(void *);
00168 int       MSS_Create(const char *path, mode_t, XrdOucEnv &);
00169 void     *MSS_Opendir(const char *, int &rc);
00170 int       MSS_Readdir(void *fd, char *buff, int blen);
00171 int       MSS_Remdir(const char *, const char *) {return -ENOTSUP;}
00172 int       MSS_Rename(const char *, const char *);
00173 int       MSS_Stat(const char *, struct stat *);
00174 int       MSS_Unlink(const char *);
00175 
00176 static const int MaxArgs = 15;
00177 
00178 char     *ConfigFN;       // -> Pointer to the config file name
00179 int       Hard_FD_Limit;  //    Hard file descriptor limit
00180 int       MaxTwiddle;     //    Maximum seconds of internal wait
00181 char     *LocalRoot;      // -> Path prefix for local  filename
00182 char     *RemoteRoot;     // -> Path prefix for remote filename
00183 int       StageRealTime;  //    If 1, Invoke stage command on demand
00184 int       StageAsync;     //    If 1, return EINPROGRESS to the caller
00185 int       StageCreate;    //    If 1, use open path to create files
00186 int       StageFormat;    //    Format for default stagecmd
00187 char     *StageCmd;       // -> Staging command to use
00188 char     *StageMsg;       // -> Staging message to be passed
00189 XrdOucMsubs *StageSnd;    // -> Parsed Message
00190 
00191 char     *StageEvents;    // -> file:////<adminpath> if async staging
00192 int       StageEvSize;    //    Length of above
00193 int       StageActLen;    //    Length of below
00194 char     *StageAction;    // -> "wq " if sync | "wfn " if async
00195 
00196 char     *StageArg[MaxArgs];
00197 int       StageAln[MaxArgs];
00198 int       StageAnum;      //    Count of valid Arg/Aln array elements
00199 char     *MSSgwCmd;       // -> MSS Gateway command to use
00200 int       MSSgwTMO;       //    MSS Gateway command response timeout
00201 long long MaxDBsize;      //    Maximum database size (*obsolete*)
00202 int       FDFence;        //    Smallest file FD number allowed
00203 int       FDLimit;        //    Largest  file FD number allowed
00204 unsigned long long DirFlags;//  Default directory settings
00205 int       Trace;          //    Trace flags
00206 int       Solitary;       //    True if running in stand-alone mode
00207 char     *CompSuffix;     // -> Compressed file suffix or null for autodetect
00208 int       CompSuflen;     //    Length of suffix
00209 int       OptFlags;       //    General option flags
00210 char     *DeprLine;       //    Temporrary to catch deprecated options
00211 
00212 char             *N2N_Lib;   // -> Name2Name Library Path
00213 char             *N2N_Parms; // -> Name2Name Object Parameters
00214 XrdOucName2Name  *lcl_N2N;   // -> File mapper for local  files
00215 XrdOucName2Name  *rmt_N2N;   // -> File mapper for remote files
00216 XrdOucName2Name  *the_N2N;   // -> File mapper object
00217 XrdOucPListAnchor RPList;    //    The real path list
00218 OssDPath         *DPList;    //    The stat path list
00219 int               lenDP;
00220 short             numDP;
00221 short             numCG;
00222    
00223          XrdOssSys();
00224 virtual ~XrdOssSys() {}
00225 
00226 protected:
00227 // Cache management related data and methods
00228 //
00229 long long minalloc;          //    Minimum allocation
00230 int       ovhalloc;          //    Allocation overage
00231 int       fuzalloc;          //    Allocation fuzz
00232 int       cscanint;          //    Seconds between cache scans
00233 int       xfrspeed;          //    Average transfer speed (bytes/second)
00234 int       xfrovhd;           //    Minimum seconds to get a file
00235 int       xfrhold;           //    Second hold limit on failing requests
00236 int       xfrkeep;           //    Second keep queued requests
00237 int       xfrthreads;        //    Number of threads for staging
00238 int       xfrtcount;         //    Actual count of threads (used for dtr)
00239 long long pndbytes;          //    Total bytes to be staged (pending)
00240 long long stgbytes;          //    Total bytes being staged (active)
00241 long long totbytes;          //    Total bytes were  staged (active+pending)
00242 int       totreqs;           //    Total   successful requests
00243 int       badreqs;           //    Total unsuccessful requests
00244 
00245 XrdOucProg     *StageProg;    //    Command or manager than handles staging
00246 XrdOucProg     *MSSgwProg;    //    Command for MSS meta-data operations
00247 
00248 char           *UDir;         // -> Usage logdir
00249 char           *QFile;        // -> Quota file
00250 
00251 int                Alloc_Cache(const char *, mode_t, XrdOucEnv &);
00252 int                Alloc_Local(const char *, mode_t, XrdOucEnv &);
00253 int                BreakLink(const char *local_path, struct stat &statbuff);
00254 int                CalcTime();
00255 int                CalcTime(XrdOssStage_Req *req);
00256 void               doScrub();
00257 int                Find(XrdOssStage_Req *req, void *carg);
00258 int                getCname(const char *path, struct stat *sbuff, char *cgbuff);
00259 int                getStats(char *buff, int blen);
00260 int                GetFile(XrdOssStage_Req *req);
00261 int                getID(const char *, XrdOucEnv &, char *, int);
00262 time_t             HasFile(const char *fn, const char *sfx, time_t *mTime=0);
00263 int                Stage_QT(const char *, const char *, XrdOucEnv &, int, mode_t);
00264 int                Stage_RT(const char *, const char *, XrdOucEnv &, unsigned long long);
00265 
00266 // Configuration related methods
00267 //
00268 int    chkDep(const char *var);
00269 void   ConfigMio(XrdSysError &Eroute);
00270 int    ConfigN2N(XrdSysError &Eroute);
00271 int    ConfigProc(XrdSysError &Eroute);
00272 void   ConfigSpace();
00273 void   ConfigSpace(const char *Lfn);
00274 int    ConfigStage(XrdSysError &Eroute);
00275 void   ConfigStats(XrdSysError &Eroute);
00276 void   ConfigStats(dev_t Devnum, char *lP);
00277 int    ConfigXeq(char *, XrdOucStream &, XrdSysError &);
00278 void   List_Path(const char *, const char *, unsigned long long, XrdSysError &);
00279 int    xalloc(XrdOucStream &Config, XrdSysError &Eroute);
00280 int    xcache(XrdOucStream &Config, XrdSysError &Eroute);
00281 int    xcacheBuild(char *grp, char *fn, int isxa, XrdSysError &Eroute);
00282 int    xcompdct(XrdOucStream &Config, XrdSysError &Eroute);
00283 int    xcachescan(XrdOucStream &Config, XrdSysError &Eroute);
00284 int    xdefault(XrdOucStream &Config, XrdSysError &Eroute);
00285 int    xfdlimit(XrdOucStream &Config, XrdSysError &Eroute);
00286 int    xmaxdbsz(XrdOucStream &Config, XrdSysError &Eroute);
00287 int    xmemf(XrdOucStream &Config, XrdSysError &Eroute);
00288 int    xnml(XrdOucStream &Config, XrdSysError &Eroute);
00289 int    xpath(XrdOucStream &Config, XrdSysError &Eroute);
00290 int    xstg(XrdOucStream &Config, XrdSysError &Eroute);
00291 int    xusage(XrdOucStream &Config, XrdSysError &Eroute);
00292 int    xtrace(XrdOucStream &Config, XrdSysError &Eroute);
00293 int    xxfr(XrdOucStream &Config, XrdSysError &Eroute);
00294 
00295 // Mass storage related methods
00296 //
00297 int    tranmode(char *);
00298 int    MSS_Xeq(XrdOucStream **xfd, int okerr,
00299                const char *cmd, const char *arg1=0, const char *arg2=0);
00300 
00301 // Other methods
00302 //
00303 int    RenameLink(char *old_path, char *new_path);
00304 int    RenameLink2(int Llen, char *oLnk, char *old_path,
00305                              char *nLnk, char *new_path);
00306 };
00307 
00308 /******************************************************************************/
00309 /*                  A P I   S p e c i f i c   D e f i n e s                   */
00310 /******************************************************************************/
00311 
00312 // The Check_RO macro is valid only for XrdOssSys objects.
00313 //
00314 #define Check_RO(act, flags, path, opname) \
00315    XRDEXP_REMOTE & (flags = PathOpts(path)); \
00316    if (flags & XRDEXP_NOTRW) \
00317       return OssEroute.Emsg(#act, -XRDOSS_E8005, opname, path)
00318 #endif

Generated on Wed Sep 1 2010 for xrootd by  doxygen 1.7.1