File indexing completed on 2026-01-08 10:33:33
0001 #ifndef _XRDOSS_API_H
0002 #define _XRDOSS_API_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include <sys/types.h>
0034 #include <cerrno>
0035 #include "XrdSys/XrdSysHeaders.hh"
0036
0037 #include "XrdOss/XrdOss.hh"
0038 #include "XrdOss/XrdOssConfig.hh"
0039 #include "XrdOss/XrdOssError.hh"
0040 #include "XrdOss/XrdOssStatInfo.hh"
0041 #include "XrdOuc/XrdOucExport.hh"
0042 #include "XrdOuc/XrdOucPList.hh"
0043 #include "XrdOuc/XrdOucStream.hh"
0044 #include "XrdSys/XrdSysError.hh"
0045 #include "XrdSys/XrdSysPthread.hh"
0046
0047
0048
0049
0050
0051 class XrdOssDir : public XrdOssDF
0052 {
0053 public:
0054 int Close(long long *retsz=0);
0055 int Opendir(const char *, XrdOucEnv &);
0056 int Readdir(char *buff, int blen);
0057 int StatRet(struct stat *buff);
0058 int getFD() {return fd;}
0059
0060
0061 XrdOssDir(const char *tid, DIR *dP=0)
0062 : XrdOssDF(tid, DF_isDir),
0063 lclfd(dP), mssfd(0), Stat(0), ateof(false),
0064 isopen(dP != 0), dOpts(0) {if (dP) fd = dirfd(dP);}
0065
0066 ~XrdOssDir() {if (isopen) Close();}
0067 private:
0068 DIR *lclfd;
0069 void *mssfd;
0070 struct stat *Stat;
0071 bool ateof;
0072 bool isopen;
0073 unsigned char dOpts;
0074 static const int isStage = 0x01;
0075 static const int noCheck = 0x02;
0076 static const int noDread = 0x04;
0077 };
0078
0079
0080
0081
0082
0083 class oocx_CXFile;
0084 class XrdSfsAio;
0085 class XrdOssCache_FS;
0086 class XrdOssMioFile;
0087
0088 class XrdOssFile : public XrdOssDF
0089 {
0090 public:
0091
0092
0093
0094
0095 virtual int Close(long long *retsz=0);
0096 virtual int Open(const char *, int, mode_t, XrdOucEnv &);
0097
0098 int Fchmod(mode_t mode);
0099 int Fctl(int cmd, int alen, const char *args, char **resp=0);
0100 void Flush();
0101 int Fstat(struct stat *);
0102 int Fsync();
0103 int Fsync(XrdSfsAio *aiop);
0104 int Ftruncate(unsigned long long);
0105 int getFD() {return fd;}
0106 off_t getMmap(void **addr);
0107 int isCompressed(char *cxidp=0);
0108 ssize_t Read( off_t, size_t);
0109 ssize_t Read( void *, off_t, size_t);
0110 int Read(XrdSfsAio *aiop);
0111 ssize_t ReadV(XrdOucIOVec *readV, int);
0112 ssize_t ReadRaw( void *, off_t, size_t);
0113 ssize_t Write(const void *, off_t, size_t);
0114 int Write(XrdSfsAio *aiop);
0115
0116
0117 XrdOssFile(const char *tid, int fdnum=-1)
0118 : XrdOssDF(tid, DF_isFile, fdnum),
0119 cxobj(0), cacheP(0), mmFile(0),
0120 rawio(0), cxpgsz(0) {cxid[0] = '\0';}
0121
0122 virtual ~XrdOssFile() {if (fd >= 0) Close();}
0123
0124 private:
0125 int Open_ufs(const char *, int, int, unsigned long long);
0126
0127 static int AioFailure;
0128 oocx_CXFile *cxobj;
0129 XrdOssCache_FS *cacheP;
0130 XrdOssMioFile *mmFile;
0131 long long FSize;
0132 int rawio;
0133 int cxpgsz;
0134 char cxid[4];
0135 };
0136
0137
0138
0139
0140
0141 class XrdFrcProxy;
0142 class XrdOssCache_Group;
0143 class XrdOssCache_Space;
0144 class XrdOssCreateInfo;
0145 class XrdOucMsubs;
0146 class XrdOucName2Name;
0147 class XrdOucProg;
0148 class XrdOssSpace;
0149 class XrdOssStage_Req;
0150
0151 struct XrdVersionInfo;
0152
0153 class XrdOssSys : public XrdOss
0154 {
0155 public:
0156 virtual XrdOssDF *newDir(const char *tident)
0157 {return (XrdOssDF *)new XrdOssDir(tident);}
0158 virtual XrdOssDF *newFile(const char *tident)
0159 {return (XrdOssDF *)new XrdOssFile(tident);}
0160
0161 int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
0162 int Configure(const char *, XrdSysError &, XrdOucEnv *envP);
0163 void Config_Display(XrdSysError &);
0164 virtual
0165 int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0);
0166 uint64_t Features() {return XRDOSS_HASNAIO;}
0167 int GenLocalPath(const char *, char *);
0168 int GenRemotePath(const char *, char *);
0169 int Init(XrdSysLogger *, const char *, XrdOucEnv *envP);
0170 int Init(XrdSysLogger *lP, const char *cP) {return Init(lP, cP, 0);}
0171 int IsRemote(const char *path)
0172 {return (RPList.Find(path) & XRDEXP_REMOTE) != 0;}
0173 int Lfn2Pfn(const char *Path, char *buff, int blen);
0174 const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc);
0175 int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0);
0176 int Mkpath(const char *, mode_t mode);
0177 unsigned long long PathOpts(const char *path) {return RPList.Find(path);}
0178 int Reloc(const char *tident, const char *path,
0179 const char *cgName, const char *anchor=0);
0180 int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0);
0181 int Rename(const char *, const char *,
0182 XrdOucEnv *eP1=0, XrdOucEnv *eP2=0);
0183 virtual
0184 int Stage(const char *, const char *, XrdOucEnv &, int, mode_t, unsigned long long );
0185 void *Stage_In(void *carg);
0186 int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *Env=0);
0187 int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *Env=0);
0188 int StatFS(const char *path, unsigned long long &Opt,
0189 long long &fSize, long long &fSpace);
0190 int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen);
0191 int StatPF(const char *, struct stat *, int);
0192 int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0);
0193 int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *Env=0);
0194 int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *Env=0);
0195 int Truncate(const char *, unsigned long long Size, XrdOucEnv *eP=0);
0196 int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0);
0197
0198 int Stats(char *bp, int bl);
0199
0200 static int AioInit();
0201 static int AioAllOk;
0202
0203 static char tryMmap;
0204 static char chkMmap;
0205
0206 int MSS_Closedir(void *);
0207 int MSS_Create(const char *path, mode_t, XrdOucEnv &);
0208 void *MSS_Opendir(const char *, int &rc);
0209 int MSS_Readdir(void *fd, char *buff, int blen);
0210 int MSS_Remdir(const char *, const char *) {return -ENOTSUP;}
0211 int MSS_Rename(const char *, const char *);
0212 int MSS_Stat(const char *, struct stat *buff=0);
0213 int MSS_Unlink(const char *);
0214
0215 static const int MaxArgs = 15;
0216
0217 char *ConfigFN;
0218 char *LocalRoot;
0219 char *RemoteRoot;
0220 int MaxTwiddle;
0221 int StageRealTime;
0222 int StageAsync;
0223 int StageCreate;
0224 int StageFormat;
0225 char *StageCmd;
0226 char *StageMsg;
0227 XrdOucMsubs *StageSnd;
0228 XrdFrcProxy *StageFrm;
0229
0230 char *StageEvents;
0231 int StageEvSize;
0232 int StageActLen;
0233 char *StageAction;
0234
0235 char *StageArg[MaxArgs];
0236 int StageAln[MaxArgs];
0237 int StageAnum;
0238 char *RSSCmd;
0239 int isMSSC;
0240 int RSSTout;
0241 long long MaxSize;
0242 int FDFence;
0243 int FDLimit;
0244 unsigned long long DirFlags;
0245 int Trace;
0246 int Solitary;
0247 int OptFlags;
0248
0249 XrdOucPListAnchor SPList;
0250 #define spAssign 1
0251
0252 char *N2N_Lib;
0253 char *N2N_Parms;
0254 XrdOucName2Name *lcl_N2N;
0255 XrdOucName2Name *rmt_N2N;
0256 XrdOucName2Name *the_N2N;
0257 XrdOucPListAnchor RPList;
0258 OssDPath *DPList;
0259 int lenDP;
0260 short numDP;
0261 short numCG;
0262
0263 char *STT_Lib;
0264 char *STT_Parms;
0265 union {
0266 XrdOssStatInfo_t STT_Func;
0267 XrdOssStatInfo2_t STT_Fund;
0268 };
0269 int STT_PreOp;
0270 char STT_DoN2N;
0271 char STT_V2;
0272 char STT_DoARE;
0273
0274 long long prPBits;
0275 long long prPMask;
0276 int prPSize;
0277 int prBytes;
0278 int prActive;
0279 short prDepth;
0280 short prQSize;
0281
0282 XrdVersionInfo *myVersion;
0283
0284 XrdOssSys();
0285 virtual ~XrdOssSys() {}
0286
0287 protected:
0288
0289
0290 long long minalloc;
0291 int ovhalloc;
0292 int fuzalloc;
0293 int cscanint;
0294 int xfrspeed;
0295 int xfrovhd;
0296 int xfrhold;
0297 int xfrkeep;
0298 int xfrthreads;
0299 int xfrtcount;
0300 long long pndbytes;
0301 long long stgbytes;
0302 long long totbytes;
0303 int totreqs;
0304 int badreqs;
0305
0306 XrdOucProg *StageProg;
0307 XrdOucProg *RSSProg;
0308
0309 char *UDir;
0310 char *QFile;
0311 char *xfrFdir;
0312 int xfrFdln;
0313 short USync;
0314 bool pfcMode;
0315
0316 int Alloc_Cache(XrdOssCreateInfo &, XrdOucEnv &);
0317 int Alloc_Local(XrdOssCreateInfo &, XrdOucEnv &);
0318 int BreakLink(const char *local_path, struct stat &statbuff);
0319 int CalcTime();
0320 int CalcTime(XrdOssStage_Req *req);
0321 int SetFattr(XrdOssCreateInfo &crInfo, int datfd, time_t mtime);
0322 void doScrub();
0323 int Find(XrdOssStage_Req *req, void *carg);
0324 int getCname(const char *path, struct stat *sbuff, char *cgbuff);
0325 int getStats(char *buff, int blen);
0326 int GetFile(XrdOssStage_Req *req);
0327 int getID(const char *, XrdOucEnv &, char *, int);
0328 time_t HasFile(const char *fn, const char *sfx, time_t *mTime=0);
0329 int Stage_QT(const char *, const char *, XrdOucEnv &, int, mode_t);
0330 int Stage_RT(const char *, const char *, XrdOucEnv &, unsigned long long);
0331
0332
0333
0334 void ConfigCache(XrdSysError &Eroute, bool pass2=false);
0335 void ConfigMio(XrdSysError &Eroute);
0336 int ConfigN2N(XrdSysError &Eroute, XrdOucEnv *envP);
0337 int ConfigProc(XrdSysError &Eroute);
0338 void ConfigSpace(XrdSysError &Eroute);
0339 void ConfigSpace(const char *Lfn);
0340 void ConfigSpath(XrdSysError &Eroute, const char *Pn,
0341 unsigned long long &Fv, int noMSS);
0342 int ConfigStage(XrdSysError &Eroute);
0343 int ConfigStageC(XrdSysError &Eroute);
0344 int ConfigStatLib(XrdSysError &Eroute, XrdOucEnv *envP);
0345 void ConfigStats(XrdSysError &Eroute);
0346 void ConfigStats(dev_t Devnum, char *lP);
0347 int ConfigXeq(char *, XrdOucStream &, XrdSysError &);
0348 void List_Path(const char *, const char *, unsigned long long, XrdSysError &);
0349 int xalloc(XrdOucStream &Config, XrdSysError &Eroute);
0350 int xcache(XrdOucStream &Config, XrdSysError &Eroute);
0351 int xcachescan(XrdOucStream &Config, XrdSysError &Eroute);
0352 int xdefault(XrdOucStream &Config, XrdSysError &Eroute);
0353 int xfdlimit(XrdOucStream &Config, XrdSysError &Eroute);
0354 int xmaxsz(XrdOucStream &Config, XrdSysError &Eroute);
0355 int xmemf(XrdOucStream &Config, XrdSysError &Eroute);
0356 int xnml(XrdOucStream &Config, XrdSysError &Eroute);
0357 int xpath(XrdOucStream &Config, XrdSysError &Eroute);
0358 int xprerd(XrdOucStream &Config, XrdSysError &Eroute);
0359 int xspace(XrdOucStream &Config, XrdSysError &Eroute, int *isCD=0);
0360 int xspace(XrdOucStream &Config, XrdSysError &Eroute,
0361 const char *grp, bool isAsgn);
0362 int xspaceBuild(OssSpaceConfig &sInfo, XrdSysError &Eroute);
0363 int xstg(XrdOucStream &Config, XrdSysError &Eroute);
0364 int xstl(XrdOucStream &Config, XrdSysError &Eroute);
0365 int xusage(XrdOucStream &Config, XrdSysError &Eroute);
0366 int xtrace(XrdOucStream &Config, XrdSysError &Eroute);
0367 int xxfr(XrdOucStream &Config, XrdSysError &Eroute);
0368
0369
0370
0371 int tranmode(char *);
0372 int MSS_Xeq(XrdOucStream **xfd, int okerr,
0373 const char *cmd, const char *arg1=0, const char *arg2=0);
0374
0375
0376
0377 int RenameLink(char *old_path, char *new_path);
0378 int RenameLink3(char *cPath, char *old_path, char *new_path);
0379 };
0380
0381
0382
0383
0384
0385
0386
0387 #define Check_RO(act, flags, path, opname) \
0388 XRDEXP_REMOTE & (flags = PathOpts(path)); \
0389 if (flags & XRDEXP_NOTRW) \
0390 return OssEroute.Emsg(#act, -XRDOSS_E8005, opname, path)
0391
0392 #define Check_RW(act, path, opname) \
0393 if (PathOpts(path) & XRDEXP_NOTRW) \
0394 return OssEroute.Emsg(#act, -XRDOSS_E8005, opname, path)
0395 #endif