diff --git a/src/XrdOfs/XrdOfsConfig.cc b/src/XrdOfs/XrdOfsConfig.cc index a893cb8be17..24cad5d596e 100644 --- a/src/XrdOfs/XrdOfsConfig.cc +++ b/src/XrdOfs/XrdOfsConfig.cc @@ -262,6 +262,7 @@ int XrdOfs::Configure(XrdSysError &Eroute, XrdOucEnv *EnvInfo) { if (!ofsConfig->Load(piOpts, EnvInfo)) NoGo = 1; else {ofsConfig->Plugin(XrdOfsOss); ossFeatures = XrdOfsOss->Features(); + if (ossFeatures & XRDOSS_HASNOSF) FeatureSet |= XrdSfs::hasNOSF; if (xrdEnv) xrdEnv->PutPtr("XrdOss*", XrdOfsOss); ofsConfig->Plugin(Cks); CksPfn = !ofsConfig->OssCks(); @@ -324,24 +325,25 @@ int XrdOfs::Configure(XrdSysError &Eroute, XrdOucEnv *EnvInfo) { // if (!NoGo && evsObject) NoGo = evsObject->Start(&Eroute); -// If POSC processing is enabled (as by default) do it. Warning! This must be -// the last item in the configuration list as we need a working filesystem. -// Note that in proxy mode we always disable posc! -// - if (getenv("XRDXROOTD_NOPOSC")) - {if (poscAuto != -1 && !NoGo) - Eroute.Say("Config POSC has been disabled by the osslib plugin."); - } else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute); - // If the OSS plugin is really a proxy. If it is, it will export its origin. // We also suppress translating lfn to pfn (usually done via osslib +cksio). +// Note: consulting the ENVAR below is historic and remains for compatibility // - if (getenv("XRDXROOTD_PROXY")) + if (ossFeatures & XRDOSS_HASPRXY || getenv("XRDXROOTD_PROXY")) {OssIsProxy = 1; CksPfn = false; FeatureSet |= XrdSfs::hasPRXY; } +// If POSC processing is enabled (as by default) do it. Warning! This must be +// the last item in the configuration list as we need a working filesystem. +// Note that in proxy mode we always disable posc! +// + if (OssIsProxy || getenv("XRDXROOTD_NOPOSC")) + {if (poscAuto != -1 && !NoGo) + Eroute.Say("Config POSC has been disabled by the osslib plugin."); + } else if (poscAuto != -1 && !NoGo) NoGo |= ConfigPosc(Eroute); + // Setup statistical monitoring // OfsStats.setRole(myRole); diff --git a/src/XrdOss/XrdOss.hh b/src/XrdOss/XrdOss.hh index e828e52728d..ce9208526bd 100644 --- a/src/XrdOss/XrdOss.hh +++ b/src/XrdOss/XrdOss.hh @@ -170,7 +170,7 @@ virtual int Ftruncate(unsigned long long) {return -EISDIR;} //! returned. Note that zero length files cannot be memory mapped. //----------------------------------------------------------------------------- -virtual off_t getMmap(void **) {return 0;} +virtual off_t getMmap(void **addr) {*addr = 0; return 0;} //----------------------------------------------------------------------------- //! Return file compression charectistics. @@ -181,7 +181,7 @@ virtual off_t getMmap(void **) {return 0;} //! zero is returned (file not compressed). //----------------------------------------------------------------------------- -virtual int isCompressed(char *cxidp=0) {(void)cxidp; return -EISDIR;} +virtual int isCompressed(char *cxidp=0) {(void)cxidp; return 0;} //----------------------------------------------------------------------------- //! Open a file. @@ -416,7 +416,7 @@ virtual int Fctl(int cmd, int alen, const char *args, char **resp=0); //! @return -1 if there is no file descriptor or a non-negative FD number. //----------------------------------------------------------------------------- -virtual int getFD() {return fd;} +virtual int getFD() {return -1;} // Must override to support sendfile() //----------------------------------------------------------------------------- //! Return trace identifier associated with this object. @@ -468,6 +468,7 @@ short rsvd; // Reserved #define XRDOSS_HASPGRW 0x0000000000000001ULL #define XRDOSS_HASFSCS 0x0000000000000002ULL #define XRDOSS_HASPRXY 0x0000000000000004ULL +#define XRDOSS_HASNOSF 0x0000000000000008ULL // Options that can be passed to Stat() // diff --git a/src/XrdPss/XrdPss.cc b/src/XrdPss/XrdPss.cc index 423e5a0cd2d..4ce7700099c 100644 --- a/src/XrdPss/XrdPss.cc +++ b/src/XrdPss/XrdPss.cc @@ -148,7 +148,7 @@ XrdOss *XrdOssGetStorageSystem2(XrdOss *native_oss, XrdPssSys::XrdPssSys() : LocalRoot(0), theN2N(0), DirFlags(0), myVersion(&XrdVERSIONINFOVAR(XrdOssGetStorageSystem2)), - myFeatures(XRDOSS_HASPRXY) + myFeatures(XRDOSS_HASPRXY|XRDOSS_HASNOSF) {} /******************************************************************************/ @@ -1035,45 +1035,6 @@ int XrdPssFile::Ftruncate(unsigned long long flen) return (XrdPosixXrootd::Ftruncate(fd, flen) ? -errno : XrdOssOK); } - -/******************************************************************************/ -/* g e t M m a p */ -/******************************************************************************/ - -/* - Function: Indicate whether or not file is memory mapped. - - Input: addr - Points to an address which will receive the location - memory where the file is mapped. If the address is - null, true is returned if a mapping exist. - - Output: Returns the size of the file if it is memory mapped (see above). - Otherwise, zero is returned and addr is set to zero. -*/ -off_t XrdPssFile::getMmap(void **addr) // Not Supported for proxies -{ - if (addr) *addr = 0; - return 0; -} - -/******************************************************************************/ -/* i s C o m p r e s s e d */ -/******************************************************************************/ - -/* - Function: Indicate whether or not file is compressed. - - Input: cxidp - Points to a four byte buffer to hold the compression - algorithm used if the file is compressed or null. - - Output: Returns the region size which is 0 if the file is not compressed. - If cxidp is not null, the algorithm is returned only if the file - is compressed. -*/ -int XrdPssFile::isCompressed(char *cxidp) // Not supported for proxies -{ - return 0; -} /******************************************************************************/ /* P 2 D S T */ diff --git a/src/XrdPss/XrdPss.hh b/src/XrdPss/XrdPss.hh index 9a685f196f9..97c9058a605 100644 --- a/src/XrdPss/XrdPss.hh +++ b/src/XrdPss/XrdPss.hh @@ -53,10 +53,12 @@ int Opendir(const char *, XrdOucEnv &); int Readdir(char *buff, int blen); // Constructor and destructor - XrdPssDir(const char *tid) : tident(tid), myDir(0) {} + XrdPssDir(const char *tid) + : XrdOssDF(tid, XrdOssDF::DF_isDir|XrdOssDF::DF_isProxy), + myDir(0) {} + ~XrdPssDir() {if (myDir) Close();} private: -const char *tident; DIR *myDir; }; @@ -83,8 +85,6 @@ int Fstat(struct stat *); int Fsync(); int Fsync(XrdSfsAio *aiop); int Ftruncate(unsigned long long); -off_t getMmap(void **addr); -int isCompressed(char *cxidp=0); ssize_t Read( off_t, size_t); ssize_t Read( void *, off_t, size_t); int Read(XrdSfsAio *aiop); @@ -94,8 +94,9 @@ ssize_t Write(const void *, off_t, size_t); int Write(XrdSfsAio *aiop); // Constructor and destructor - XrdPssFile(const char *tid) : tident(tid), tpcPath(0), entity(0) - {fd = -1;} + XrdPssFile(const char *tid) + : XrdOssDF(tid, XrdOssDF::DF_isFile|XrdOssDF::DF_isProxy), + tpcPath(0), entity(0) {} virtual ~XrdPssFile() {if (fd >= 0) Close(); if (tpcPath) free(tpcPath); @@ -103,7 +104,6 @@ virtual ~XrdPssFile() {if (fd >= 0) Close(); private: -const char *tident; char *tpcPath; const XrdSecEntity *entity; diff --git a/src/XrdSfs/XrdSfsFlags.hh b/src/XrdSfs/XrdSfsFlags.hh index 316be6b9e65..315a8ae1b69 100644 --- a/src/XrdSfs/XrdSfsFlags.hh +++ b/src/XrdSfs/XrdSfsFlags.hh @@ -66,6 +66,9 @@ static const uint64_t hasPRXY = 0x0000000000000080LL; //! Feature: Supports SfsXio static const uint64_t hasSXIO = 0x0000000000000100LL; + +//! Feature: Supports no sendfile +static const uint64_t hasNOSF = 0x0000000000000200LL; } //----------------------------------------------------------------------------- diff --git a/src/XrdXrootd/XrdXrootdConfig.cc b/src/XrdXrootd/XrdXrootdConfig.cc index e43272fcc0d..1ec85bf746e 100644 --- a/src/XrdXrootd/XrdXrootdConfig.cc +++ b/src/XrdXrootd/XrdXrootdConfig.cc @@ -85,6 +85,7 @@ #include "Xrd/XrdBuffer.hh" #include "Xrd/XrdInet.hh" +#include "Xrd/XrdLink.hh" /******************************************************************************/ /* P r o t o c o l C o m m a n d L i n e O p t i o n s */ @@ -310,15 +311,26 @@ int XrdXrootdProtocol::Configure(char *parms, XrdProtocol_Config *pi) // Initialiaze for AIO // - if (getenv("XRDXROOTD_NOAIO")) as_noaio = 1; - else if (!as_noaio) XrdXrootdAioReq::Init(as_segsize, as_maxperreq, as_maxpersrv); - else eDest.Say("Config warning: asynchronous I/O has been disabled!"); + if (!as_noaio) XrdXrootdAioReq::Init(as_segsize, as_maxperreq, as_maxpersrv); + else eDest.Say("Config asynchronous I/O has been disabled!"); -// Create the file lock manager +// Establish final sendfile processing mode. This may be turned off by the +// link or by the SFS plugin usually because ot's a proxy. +// + const char *why = 0; + if (!as_nosf) + {if (fsFeatures & XrdSfs::hasNOSF) why = "file system plugin."; + else if (!XrdLink::sfOK) why = "OS kernel."; + if (why) + {as_nosf = 1; + eDest.Say("Config sendfile has been disabled by ", why); + } + } + +// Create the file lock manager and initialize file handling // Locker = (XrdXrootdFileLock *)new XrdXrootdFileLock1(); XrdXrootdFile::Init(Locker, &eDest, as_nosf == 0); - if (as_nosf) eDest.Say("Config warning: sendfile I/O has been disabled!"); // Schedule protocol object cleanup (also advise the transit protocol) // @@ -567,7 +579,7 @@ int XrdXrootdProtocol::CheckTLS(const char *tlsProt) // TLS authnetication based protocols should the login phase not have TLS. // if (tlsProt && !(tlsCap & Req_TLSLogin)) - {eDest.Say("Config warning: Authentication protocol(s)", tlsProt, + {eDest.Say("Config Authentication protocol(s)", tlsProt, " require TLS; login now requires TLS."); myRole |= kXR_tlsLogin; tlsCap |= Req_TLSLogin; diff --git a/src/XrdXrootd/XrdXrootdFile.cc b/src/XrdXrootd/XrdXrootdFile.cc index 0d19781323c..d4bedcef78c 100644 --- a/src/XrdXrootd/XrdXrootdFile.cc +++ b/src/XrdXrootd/XrdXrootdFile.cc @@ -79,32 +79,33 @@ static const unsigned long heldMask = ~1UL; /******************************************************************************/ XrdXrootdFile::XrdXrootdFile(const char *id, const char *path, XrdSfsFile *fp, - char mode, bool async, int sfok, struct stat *sP) + char mode, bool async, struct stat *sP) + : XrdSfsp(fp), mmAddr(0), FileKey(strdup(path)), + FileMode(mode), AsyncMode(async), fhProc(0), + ID(id) { static XrdSysMutex seqMutex; struct stat buf; off_t mmSize; - XrdSfsp = fp; - FileKey = strdup(path); - mmAddr = 0; - FileMode = mode; - AsyncMode= (async ? 1 : 0); - fhProc = 0; - ID = id; - +// Initialize statistical counters +// Stats.Init(); -// Get the file descriptor number (none if not a regular file) +// Get the file descriptor number for sendfile() processing // - if (fp->fctl(SFS_FCTL_GETFD, 0, fp->error) != SFS_OK) fdNum = -1; - else fdNum = fp->error.getErrInfo(); - sfEnabled = (sfOK && sfok && (fdNum >= 0||fdNum==(int)SFS_SFIO_FDVAL) ? 1:0); + if (!sfOK || fp->fctl(SFS_FCTL_GETFD, 0, fp->error) != SFS_OK) + {fdNum = -1; + sfEnabled = false; + } else { + fdNum = fp->error.getErrInfo(); + sfEnabled = (fdNum >= 0 || fdNum == (int)SFS_SFIO_FDVAL); + } // Determine if file is memory mapped // - if (fp->getMmap((void **)&mmAddr, mmSize) != SFS_OK) isMMapped = 0; - else {isMMapped = (mmSize ? 1 : 0); + if (fp->getMmap((void **)&mmAddr, mmSize) != SFS_OK) isMMapped = false; + else {isMMapped = (mmSize ? true : false); Stats.fSize = static_cast(mmSize); } diff --git a/src/XrdXrootd/XrdXrootdFile.hh b/src/XrdXrootd/XrdXrootdFile.hh index a2cfcdc328a..d4c4a9d0760 100644 --- a/src/XrdXrootd/XrdXrootdFile.hh +++ b/src/XrdXrootd/XrdXrootdFile.hh @@ -105,9 +105,9 @@ union {char *mmAddr; // Memory mapped location, if any }; char *FileKey; // -> File hash name (actual file name now) char FileMode; // 'r' or 'w' -char AsyncMode; // 1 -> if file in async r/w mode -char isMMapped; // 1 -> file is memory mapped -char sfEnabled; // 1 -> file is sendfile enabled +bool AsyncMode; // 1 -> if file in async r/w mode +bool isMMapped; // 1 -> file is memory mapped +bool sfEnabled; // 1 -> file is sendfile enabled union {int fdNum; // File descriptor number if regular file int fHandle; // The file handle upon close() }; @@ -119,8 +119,7 @@ XrdXrootdFileStats Stats; // File access statistics static void Init(XrdXrootdFileLock *lp, XrdSysError *erP, int sfok); XrdXrootdFile(const char *id, const char *path, XrdSfsFile *fp, - char mode='r', bool async=false, int sfOK=0, - struct stat *sP=0); + char mode='r', bool async=false, struct stat *sP=0); ~XrdXrootdFile(); private: diff --git a/src/XrdXrootd/XrdXrootdXeq.cc b/src/XrdXrootd/XrdXrootdXeq.cc index 90e712fe2e9..b43709dcfd2 100644 --- a/src/XrdXrootd/XrdXrootdXeq.cc +++ b/src/XrdXrootd/XrdXrootdXeq.cc @@ -1453,7 +1453,7 @@ int XrdXrootdProtocol::do_Open() // Obtain a hyper file object // - xp = new XrdXrootdFile(Link->ID,fn,fp,usage,isAsync,Link->sfOK,&statbuf); + xp = new XrdXrootdFile(Link->ID, fn, fp, usage, isAsync, &statbuf); if (!xp) {snprintf(ebuff, sizeof(ebuff)-1, "Insufficient memory to open %s", fn); eDest.Emsg("Xeq", ebuff);