Skip to content

Commit

Permalink
[Server] Provide better space configuration information for Xcache.
Browse files Browse the repository at this point in the history
[Server] Lay groundwork for native async I/O implementation.
  • Loading branch information
abh3 committed Jun 2, 2020
1 parent e51d6a8 commit 721ac53
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 96 deletions.
4 changes: 2 additions & 2 deletions src/XrdOss/XrdOss.cc
@@ -1,6 +1,6 @@
/******************************************************************************/
/* */
/* X r d O s s . h h */
/* X r d O s s . c c */
/* */
/* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
/* All Rights Reserved */
Expand Down Expand Up @@ -105,7 +105,7 @@ int XrdOss::StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
/* S t a t P F */
/******************************************************************************/

int XrdOss::StatPF(const char *path, struct stat *buff)
int XrdOss::StatPF(const char *path, struct stat *buff, int opts)
{
(void)path; (void)buff;
return -ENOTSUP;
Expand Down
96 changes: 61 additions & 35 deletions src/XrdOss/XrdOss.hh
Expand Up @@ -75,7 +75,7 @@ public:
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Opendir(const char *path, XrdOucEnv &env) {return -ENOTDIR;}
virtual int Opendir(const char *path, XrdOucEnv &env) {return -ENOTDIR;}

//-----------------------------------------------------------------------------
//! Get the next directory entry.
Expand All @@ -88,7 +88,7 @@ virtual int Opendir(const char *path, XrdOucEnv &env) {return -ENOTDIR;}
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Readdir(char *buff, int blen) {return -ENOTDIR;}
virtual int Readdir(char *buff, int blen) {return -ENOTDIR;}

//-----------------------------------------------------------------------------
//! Set the stat() buffer where stat information is to be placed corresponding
Expand All @@ -101,7 +101,7 @@ virtual int Readdir(char *buff, int blen) {return -ENOTDIR;}
//! @note This is a one-time call as stat structure is reused for each Readdir.
//-----------------------------------------------------------------------------

virtual int StatRet(struct stat *) {return -ENOTSUP;}
virtual int StatRet(struct stat *) {return -ENOTSUP;}

/******************************************************************************/
/* F i l e O r i e n t e d M e t h o d s */
Expand All @@ -114,13 +114,13 @@ virtual int StatRet(struct stat *) {return -ENOTSUP;}
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Fchmod(mode_t mode) {return -EISDIR;}
virtual int Fchmod(mode_t mode) {return -EISDIR;}

//-----------------------------------------------------------------------------
//! Flush filesystem cached pages for this file (used for checksums).
//-----------------------------------------------------------------------------

virtual void Flush() {}
virtual void Flush() {}

//-----------------------------------------------------------------------------
//! Return state information for this file.
Expand All @@ -130,15 +130,15 @@ virtual void Flush() {}
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Fstat(struct stat *) {return -EISDIR;}
virtual int Fstat(struct stat *buf) {return -EISDIR;}

//-----------------------------------------------------------------------------
//! Synchronize associated file with media (synchronous).
//!
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Fsync() {return -EISDIR;}
virtual int Fsync() {return -EISDIR;}

//-----------------------------------------------------------------------------
//! Synchronize associated file with media (asynchronous).
Expand All @@ -148,7 +148,7 @@ virtual int Fsync() {return -EISDIR;}
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Fsync(XrdSfsAio *aiop) {return -EISDIR;}
virtual int Fsync(XrdSfsAio *aiop) {return -EISDIR;}

//-----------------------------------------------------------------------------
//! Set the size of the associated file.
Expand All @@ -158,15 +158,7 @@ virtual int Fsync(XrdSfsAio *aiop) {return -EISDIR;}
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Ftruncate(unsigned long long) {return -EISDIR;}

//-----------------------------------------------------------------------------
//! Return the underlying file descriptor.
//!
//! @return -1 if there is no file descriptor or a non-negative FD number.
//-----------------------------------------------------------------------------

virtual int getFD() {return -1;}
virtual int Ftruncate(unsigned long long) {return -EISDIR;}

//-----------------------------------------------------------------------------
//! Return the memory mapped characteristics of the file.
Expand All @@ -178,7 +170,7 @@ virtual int getFD() {return -1;}
//! returned. Note that zero length files cannot be memory mapped.
//-----------------------------------------------------------------------------

virtual off_t getMmap(void **) {return 0;}
virtual off_t getMmap(void **) {return 0;}

//-----------------------------------------------------------------------------
//! Return file compression charectistics.
Expand All @@ -189,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 -EISDIR;}

//-----------------------------------------------------------------------------
//! Open a file.
Expand Down Expand Up @@ -287,7 +279,7 @@ virtual int pgWrite(XrdSfsAio* aoiparm, uint64_t opts);
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual ssize_t Read(off_t offset, size_t size) {return (ssize_t)-EISDIR;}
virtual ssize_t Read(off_t offset, size_t size) {return (ssize_t)-EISDIR;}

//-----------------------------------------------------------------------------
//! Read file bytes into a buffer.
Expand All @@ -312,7 +304,7 @@ virtual ssize_t Read(void *buffer, off_t offset, size_t size)
//! (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Read(XrdSfsAio *aoip) {(void)aoip; return (ssize_t)-EISDIR;}
virtual int Read(XrdSfsAio *aoip) {(void)aoip; return (ssize_t)-EISDIR;}

//-----------------------------------------------------------------------------
//! Read uncompressed file bytes into a buffer.
Expand Down Expand Up @@ -363,7 +355,7 @@ virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
//! (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int Write(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;}
virtual int Write(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;}

//-----------------------------------------------------------------------------
//! Write file bytes as directed by the write vector.
Expand Down Expand Up @@ -400,8 +392,7 @@ virtual int Close(long long *retsz=0)=0;
//
static const uint16_t DF_isDir = 0x0001; //!< Object is for a directory
static const uint16_t DF_isFile = 0x0002; //!< Object is for a file
static const uint16_t DF_isOpen = 0x0010; //!< Object target has been opened
static const uint16_t DF_isProxy = 0x0020; //!< Object is a proxy object
static const uint16_t DF_isProxy = 0x0010; //!< Object is a proxy object

uint16_t DFType() {return dfType;}

Expand All @@ -419,24 +410,44 @@ uint16_t DFType() {return dfType;}

virtual int Fctl(int cmd, int alen, const char *args, char **resp=0);

//-----------------------------------------------------------------------------
//! Return the underlying file descriptor.
//!
//! @return -1 if there is no file descriptor or a non-negative FD number.
//-----------------------------------------------------------------------------

virtual int getFD() {return fd;}

//-----------------------------------------------------------------------------
//! Return trace identifier associated with this object.
//!
//! @return Pointer to trace identifier
//-----------------------------------------------------------------------------
virtual
const char *getTID() {return tident;}

//-----------------------------------------------------------------------------
//! Constructor and Destructor
//!
//! @param dftpe - The type of the object.
//! @param tid - Pointer to the trace identifier.
//! @param dftype - The type of the object.
//! @param fdnum - The value for the file descriptor.
//-----------------------------------------------------------------------------

XrdOssDF(uint16_t dftype=0)
: pgwEOF(0), fd(-1), dfType(dftype), rsvd(0) {}
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
: tident(tid), pgwEOF(0), fd(fdnum), dfType(dftype),
rsvd(0) {}

virtual ~XrdOssDF() {}


protected:

off_t pgwEOF; // Highest short offset on pgWrite (0 means none yet)
int fd; // The associated file descriptor.
uint16_t dfType; // Type of this object
short rsvd; // Reserved
const char *tident; // Trace identifier
off_t pgwEOF; // Highest short offset on pgWrite (0 means none yet)
int fd; // The associated file descriptor.
uint16_t dfType; // Type of this object
short rsvd; // Reserved
};

/******************************************************************************/
Expand Down Expand Up @@ -729,14 +740,28 @@ virtual int StatLS(XrdOucEnv &env, const char *path,
//-----------------------------------------------------------------------------
//! Return state information on a resident physical file or directory.
//!
//! @param path - Pointer to the path in question. No translation is
//! done on this path.
//! @param path - Pointer to the path in question.
//! @param buff - Pointer to the structure where info it to be returned.
//! @param opts - Options:
//! PF_dInfo - provide bdevID in st_rdev and partID in st_dev
//! based on path. If path is nil then the contents
//! of the of buff is used as the input source.
//! PF_dNums - provide number of bdev's in st_rdev and the
//! number of partitions in st_dev. The path
//! argument is ignored. This superceeds PF_dInfo.
//! PF_isLFN - Do N2N translation on path (default is none).
//!
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int StatPF(const char *path, struct stat *buff);
static const int PF_dInfo = 0x00000001;
static const int PF_dNums = 0x00000002;
static const int PF_isLFN = 0x00000004;

virtual int StatPF(const char *path, struct stat *buff, int opts);

virtual int StatPF(const char *path, struct stat *buff)
{return StatPF(path, buff, 0);} // Backward compat

//-----------------------------------------------------------------------------
//! Return space information for a space name.
Expand Down Expand Up @@ -782,7 +807,8 @@ virtual int StatXA(const char *path, char *buff, int &blen,
//! @return 0 upon success or -errno or -osserr (see XrdOssError.hh).
//-----------------------------------------------------------------------------

virtual int StatXP(const char *, unsigned long long &, XrdOucEnv *x=0);
virtual int StatXP(const char *path, unsigned long long &attr,
XrdOucEnv *envP=0);

//-----------------------------------------------------------------------------
//! Truncate a file.
Expand Down
56 changes: 32 additions & 24 deletions src/XrdOss/XrdOssApi.cc
Expand Up @@ -494,8 +494,11 @@ int XrdOssDir::Opendir(const char *dir_path, XrdOucEnv &Env)

// Get the processing flags for this directory
//
pflags = XrdOssSS->PathOpts(dir_path);
ateof = 0;
unsigned long long pflags = XrdOssSS->PathOpts(dir_path);
if (pflags & XRDEXP_STAGE) dOpts |= isStage;
if (pflags & XRDEXP_NODREAD) dOpts |= noDread;
if (pflags & XRDEXP_NOCHECK) dOpts |= noCheck;
ateof = false;

// Generate local path
//
Expand All @@ -505,12 +508,15 @@ int XrdOssDir::Opendir(const char *dir_path, XrdOucEnv &Env)
else local_path = actual_path;
else local_path = (char *)dir_path;

// If this is a local filesystem request, open locally.
// If this is a local filesystem request, open locally. We also obtian the
// underlying file descriptor.
//
if (!(pflags & XRDEXP_STAGE) || (pflags & XRDEXP_NODREAD))
if (!(dOpts & isStage) || (dOpts & noDread))
{TRACE(Opendir, "lcl path " <<local_path <<" (" <<dir_path <<")");
if ((lclfd = opendir((char *)local_path))) {isopen = 1; return XrdOssOK;}
return -errno;
if (!(lclfd = XrdSysFD_OpenDir(local_path))) return -errno;
fd = dirfd(lclfd);
isopen = true;
return XrdOssOK;
}

// Generate remote path
Expand All @@ -528,18 +534,18 @@ int XrdOssDir::Opendir(const char *dir_path, XrdOucEnv &Env)
// by making NODREAD mean to read the local directory only (which is not always
// ideal). So, we keep the code below but comment it out for now.
//
// if ((pflags & XRDEXP_NODREAD) && !(pflags & XRDEXP_NOCHECK))
// if ((dOpts & noDread) && !(dOpts & noCheck))
// {struct stat fstat;
// if ((retc = XrdOssSS->MSS_Stat(remote_path,&fstat))) return retc;
// if (!(S_ISDIR(fstat.st_mode))) return -ENOTDIR;
// isopen = 1;
// isopen = true;
// return XrdOssOK;
// }

// Open the directory at the remote location.
//
if (!(mssfd = XrdOssSS->MSS_Opendir(remote_path, retc))) return retc;
isopen = 1;
isopen = true;
return XrdOssOK;
}

Expand Down Expand Up @@ -577,19 +583,19 @@ int XrdOssDir::Readdir(char *buff, int blen)
if ((rp = readdir(lclfd)))
{strlcpy(buff, rp->d_name, blen);
#ifdef HAVE_FSTATAT
if (Stat && fstatat(dirFD, rp->d_name, Stat, 0)) return -errno;
if (Stat && fstatat(fd, rp->d_name, Stat, 0)) return -errno;
#endif
return XrdOssOK;
}
*buff = '\0'; ateof = 1;
*buff = '\0'; ateof = true;
return -errno;
}

// Simulate the read operation, if need be.
//
if (pflags & XRDEXP_NODREAD)
if (noDread)
{if (ateof) *buff = '\0';
else {*buff = '.'; ateof = 1;}
else {*buff = '.'; ateof = true;}
return XrdOssOK;
}

Expand Down Expand Up @@ -629,14 +635,6 @@ int XrdOssDir::StatRet(struct stat *buff)
return -ENOTSUP;
#endif

// Now obtain the correct file descriptor which is special in Solaris
//
#ifdef __solaris__
dirFD = lclfd->dd_fd;
#else
dirFD = dirfd(lclfd);
#endif

// All is well
//
Stat = buff;
Expand All @@ -658,15 +656,25 @@ int XrdOssDir::Close(long long *retsz)
{
int retc;

// We do not support returing a size
//
if (retsz) *retsz = 0;

// Make sure this object is open
//
if (!isopen) return -XRDOSS_E8002;

// Close whichever handle is open
//
if (lclfd) {if (!(retc = closedir(lclfd))) lclfd = 0;}
else if (mssfd) { if (!(retc = XrdOssSS->MSS_Closedir(mssfd))) mssfd = 0;}
else retc = 0;
if (lclfd)
{if (!(retc = closedir(lclfd)))
{lclfd = 0;
isopen = false;
}
} else {
if (mssfd) { if (!(retc = XrdOssSS->MSS_Closedir(mssfd))) mssfd = 0;}
else retc = 0;
}

// Indicate whether or not we really closed this object
//
Expand Down

0 comments on commit 721ac53

Please sign in to comment.