Loading...
Searching...
No Matches
XrdOssFile Class Reference

`#include <XrdOssApi.hh>`

Inheritance diagram for XrdOssFile:
Collaboration diagram for XrdOssFile:

## Public Member Functions

| XrdOssFile (const char *tid, int fdnum=-1)
virtual | ~XrdOssFile ()
virtual int | Close (long long *retsz=0)
int | Fchmod (mode_t mode)
int | Fctl (int cmd, int alen, const char *args, char **resp=0)
void | Flush ()
| Flush filesystem cached pages for this file (used for checksums).
int | Fstat (struct stat *)
int | Fsync ()
int | Fsync (XrdSfsAio *aiop)
int | Ftruncate (unsigned long long)
int | getFD ()
off_t | getMmap (void **addr)
int | isCompressed (char *cxidp=0)
virtual int | Open (const char *, int, mode_t, XrdOucEnv &)
ssize_t | Read (off_t, size_t)
ssize_t | Read (void *, off_t, size_t)
int | Read (XrdSfsAio *aiop)
ssize_t | ReadRaw (void *, off_t, size_t)
ssize_t | ReadV (XrdOucIOVec *readV, int)
ssize_t | Write (const void *, off_t, size_t)
int | Write (XrdSfsAio *aiop)
Public Member Functions inherited from XrdOssDF
| XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
virtual | ~XrdOssDF ()
uint16_t | DFType ()
virtual const char * | getTID ()
virtual int | Opendir (const char *path, XrdOucEnv &env)
virtual ssize_t | pgRead (void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
virtual int | pgRead (XrdSfsAio *aioparm, uint64_t opts)
virtual ssize_t | pgWrite (void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
virtual int | pgWrite (XrdSfsAio *aioparm, uint64_t opts)
virtual int | Readdir (char *buff, int blen)
virtual int | StatRet (struct stat *buff)
virtual ssize_t | WriteV (XrdOucIOVec *writeV, int wrvcnt)

## Additional Inherited Members

Static Public Attributes inherited from XrdOssDF
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_isProxy = 0x0010
| Object is a proxy object.
static const uint64_t | doCalc = 0x4000000000000000ULL
| pgw: Calculate checksums
static const int | Fctl_ckpObj = 0
static const int | Fctl_utimes = 1
static const uint64_t | Verify = 0x8000000000000000ULL
| all: Verify checksums
Protected Attributes inherited from XrdOssDF
uint16_t | dfType
int | fd
off_t | pgwEOF
short | rsvd
const char * | tident

## Detailed Description

Definition at line 88 of file XrdOssApi.hh.

## Constructor & Destructor Documentation

## XrdOssFile()

XrdOssFile::XrdOssFile | ( | const char * | tid,
|  | int | fdnum = -1 )

inline

Definition at line 117 of file XrdOssApi.hh.

: XrdOssDF(tid, DF_isFile, fdnum),
cxobj(0), cacheP(0), mmFile(0),
rawio(0), cxpgsz(0) {cxid[0] = '\0';}
XrdOssDF::DF_isFile
static const uint16_t DF_isFile
Object is for a file.
Definition XrdOss.hh:393
XrdOssDF::XrdOssDF
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
Definition XrdOss.hh:444

References XrdOssDF::XrdOssDF(), and XrdOssDF::DF_isFile.

Here is the call graph for this function:

## ~XrdOssFile()

virtual XrdOssFile::~XrdOssFile | ( |  | ) |

inline virtual

Definition at line 122 of file XrdOssApi.hh.

{if (fd >= 0) Close();}
XrdOssDF::fd
int fd
Definition XrdOss.hh:455
XrdOssFile::Close
virtual int Close(long long *retsz=0)
Definition XrdOssApi.cc:813

References Close(), and XrdOssDF::fd.

Here is the call graph for this function:

## Member Function Documentation

## Close()

int XrdOssFile::Close | ( | long long * | retsz = 0 | ) |

virtual

Close a directory or file.

Parameters

  retsz | If not nil, where the size of the file is to be returned.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOssDF.

Definition at line 813 of file XrdOssApi.cc.

{
if (fd < 0) return -XRDOSS_E8004;
if (retsz || cacheP)
{struct stat buf;
int retc;
do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
if (cacheP && FSize != buf.st_size)
XrdOssCache::Adjust(cacheP, buf.st_size - FSize);
if (retsz) *retsz = buf.st_size;
}
if (close(fd)) return -errno;
if (mmFile) {XrdOssMio::Recycle(mmFile); mmFile = 0;}
#ifdef XRDOSSCX
if (cxobj) {delete cxobj; cxobj = 0;}
#endif
fd = -1; FSize = -1; cacheP = 0;
return XrdOssOK;
}
XRDOSS_E8004
#define XRDOSS_E8004
Definition XrdOssError.hh:38
XrdOssOK
#define XrdOssOK
Definition XrdOss.hh:50
close
#define close(a)
Definition XrdPosix.hh:48
fstat
#define fstat(a, b)
Definition XrdPosix.hh:62
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdOssCache::Adjust
static void Adjust(dev_t devid, off_t size)
Definition XrdOssCache.cc:397
XrdOssMio::Recycle
static void Recycle(XrdOssMioFile *mp)
Definition XrdOssMio.cc:294

References XrdOssCache::Adjust(), close, XrdOssDF::fd, fstat, XrdOssMio::Recycle(), stat, XRDOSS_E8004, and XrdOssOK.

Referenced by ~XrdOssFile().

Here is the call graph for this function:
Here is the caller graph for this function:

## Fchmod()

int XrdOssFile::Fchmod | ( | mode_t | mode | ) |

virtual

Change file mode settings.

Parameters

  mode | - The new file mode setting.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1050 of file XrdOssApi.cc.

{
return (fchmod(fd, Mode) ? -errno : XrdOssOK);
}
Mode
int Mode
Definition XrdSecgsiProxy.cc:94

References XrdOssDF::fd, Mode, and XrdOssOK.

## Fctl()

int XrdOssFile::Fctl | ( | int | cmd,
|  | int | alen,
|  | const char * | args,
|  | char ** | resp = 0 )

virtual

Reimplemented from XrdOssDF.

Definition at line 1069 of file XrdOssApi.cc.

{
const struct timeval *utArgs;
switch(cmd)
{case XrdOssDF::Fctl_utimes:
if (alen != sizeof(struct timeval)*2 || !args) return -EINVAL;
utArgs = (const struct timeval *)args;
if (futimes(fd, utArgs)) return -errno;
return XrdOssOK;
break;
default: break;
}
return -ENOTSUP;
}
XrdOssDF::Fctl_utimes
static const int Fctl_utimes
Definition XrdOss.hh:416

References XrdOssDF::Fctl_utimes, XrdOssDF::fd, and XrdOssOK.

## Flush()

void XrdOssFile::Flush | ( |  | ) |

virtual

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

Reimplemented from XrdOssDF.

Definition at line 1095 of file XrdOssApi.cc.

{
// This actually only works in Linux so we punt otherwise
//
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
if (fd>= 0)
{fdatasync(fd);
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
}
#endif
}
fdatasync
int fdatasync(int fildes)
Definition XrdPosixPreload.cc:203

References XrdOssDF::fd, and fdatasync().

Here is the call graph for this function:

## Fstat()

int XrdOssFile::Fstat | ( | struct stat * | buf | ) |

virtual

Return state information for this file.

Parameters

  buf | - Pointer to the structure where info it to be returned.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1119 of file XrdOssApi.cc.

{
return (fstat(fd, buff) ? -errno : XrdOssOK);
}

References XrdOssDF::fd, fstat, stat, and XrdOssOK.

## Fsync() [1/2]

int XrdOssFile::Fsync | ( | void |  | ) |

virtual

Synchronize associated file with media (synchronous).

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1135 of file XrdOssApi.cc.

{
return (fsync(fd) ? -errno : XrdOssOK);
}
fsync
#define fsync(a)
Definition XrdPosix.hh:64

References XrdOssDF::fd, fsync, and XrdOssOK.

Referenced by Fsync().

Here is the caller graph for this function:

## Fsync() [2/2]

int XrdOssFile::Fsync | ( | XrdSfsAio * | aiop | ) |

virtual

Synchronize associated file with media (asynchronous).

Parameters

  aiop | - Pointer to async I/O request object.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 102 of file XrdOssAio.cc.

{
#ifdef _POSIX_ASYNCHRONOUS_IO
int rc;
// Complete the aio request block and do the operation
//
if (XrdOssSys::AioAllOk)
{aiop->sfsAio.aio_fildes = fd;
aiop->sfsAio.aio_sigevent.sigev_signo = OSS_AIO_WRITE_DONE;
aiop->TIdent = tident;
// Start the operation
//
if (!(rc = aio_fsync(O_SYNC, &aiop->sfsAio))) return 0;
if (errno != EAGAIN && errno != ENOSYS) return -errno;
// Aio failed keep track of the problem (msg every 1024 events). Note
// that the handling of the counter is sloppy because we do not lock it.
//
{int fcnt = AioFailure++;
if ((fcnt & 0x3ff) == 1) OssEroute.Emsg("aio", errno, "fsync async");
}
}
#endif
// Execute this request in a synchronous fashion
//
if ((aiop->Result = Fsync())) aiop->Result = -errno;
// Simply call the write completion routine and return as if all went well
//
aiop->doneWrite();
return 0;
}
OssEroute
XrdSysError OssEroute
aiocb::aio_sigevent
struct sigevent aio_sigevent
Definition XrdSfsAio.hh:51
aiocb::aio_fildes
int aio_fildes
Definition XrdSfsAio.hh:46
XrdOssDF::tident
const char * tident
Definition XrdOss.hh:453
XrdOssFile::Fsync
int Fsync()
Definition XrdOssApi.cc:1135
XrdOssSys::AioAllOk
static int AioAllOk
Definition XrdOssApi.hh:201
XrdSfsAio::Result
ssize_t Result
Definition XrdSfsAio.hh:65
XrdSfsAio::TIdent
const char * TIdent
Definition XrdSfsAio.hh:67
XrdSfsAio::sfsAio
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
XrdSfsAio::doneWrite
virtual void doneWrite()=0
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95

References aiocb::aio_fildes, aiocb::aio_sigevent, XrdOssSys::AioAllOk, XrdSfsAio::doneWrite(), XrdOssDF::fd, Fsync(), OssEroute, XrdSfsAio::Result, XrdSfsAio::sfsAio, XrdSfsAio::TIdent, and XrdOssDF::tident.

Here is the call graph for this function:

## Ftruncate()

int XrdOssFile::Ftruncate | ( | unsigned long long | flen | ) |

virtual

Set the size of the associated file.

Parameters

  flen | - The new size of the file.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1206 of file XrdOssApi.cc.

{
off_t newlen = flen;
if (sizeof(newlen) < sizeof(flen) && (flen>>31)) return -XRDOSS_E8008;
// Note that space adjustment will occur when the file is closed, not here
//
return (ftruncate(fd, newlen) ? -errno : XrdOssOK);
}
XRDOSS_E8008
#define XRDOSS_E8008
Definition XrdOssError.hh:42
ftruncate
#define ftruncate(a, b)
Definition XrdPosix.hh:70

References XrdOssDF::fd, ftruncate, XRDOSS_E8008, and XrdOssOK.

## getFD()

int XrdOssFile::getFD | ( |  | ) |

inline virtual

Return the underlying file descriptor.

Returns
  -1 if there is no file descriptor or a non-negative FD number.

Reimplemented from XrdOssDF.

Definition at line 105 of file XrdOssApi.hh.

{return fd;}

References XrdOssDF::fd.

## getMmap()

off_t XrdOssFile::getMmap | ( | void ** | addr | ) |

virtual

Return the memory mapped characteristics of the file.

Parameters

  addr | - Pointer to where the memory mapped address is to be returned.

Returns
  If mapped, the size of the file is returned and it memory location is placed in addr. Otherwise, addr is set to zero and zero is returned. Note that zero length files cannot be memory mapped.

Reimplemented from XrdOssDF.

Definition at line 1154 of file XrdOssApi.cc.

{
if (mmFile) return (addr ? mmFile->Export(addr) : 1);
if (addr) *addr = 0;
return 0;
}

## isCompressed()

int XrdOssFile::isCompressed | ( | char * | cxidp = 0 | ) |

virtual

Return file compression charectistics.

Parameters

  cxidp | - Pointer to where the compression algorithm name returned.

Returns
  If the file is compressed, the region size if returned. Otherwise, zero is returned (file not compressed).

Reimplemented from XrdOssDF.

Definition at line 1175 of file XrdOssApi.cc.

{
if (cxpgsz)
{cxidp[0] = cxid[0]; cxidp[1] = cxid[1];
cxidp[2] = cxid[2]; cxidp[3] = cxid[3];
}
return cxpgsz;
}

## Open()

int XrdOssFile::Open | ( | const char * | path,
|  | int | Oflag,
|  | mode_t | Mode,
|  | XrdOucEnv & | env )

virtual

Open a file.

Parameters

  path | - Pointer to the path of the file to be opened.
  Oflag | - Standard open flags.
  Mode | - File open mode (ignored unless creating a file).
  env | - Reference to environmental information.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 718 of file XrdOssApi.cc.

{
unsigned long long popts;
int retc, mopts;
char actual_path[MAXPATHLEN+1], *local_path;
struct stat buf;
// Return an error if this object is already open
//
if (fd >= 0) return -XRDOSS_E8003;
else cxobj = 0;
// Construct the processing options for this path.
//
popts = XrdOssSS->PathOpts(path);
if (popts & XRDEXP_STAGE && Env.Get("oss.lcl")) popts &= ~XRDEXP_STAGE;
// Generate local path
//
if (XrdOssSS->lcl_N2N)
if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
return retc;
else local_path = actual_path;
else local_path = (char *)path;
// Check if this is a read/only filesystem
//
if (((Oflag & O_ACCMODE) != O_RDONLY) && (popts & XRDEXP_NOTRW))
{if (popts & XRDEXP_FORCERO) Oflag = O_RDONLY;
else return OssEroute.Emsg("Open",-XRDOSS_E8005,"open r/w",path);
}
// If we can open the local copy. If not found, try to stage it in if possible.
// Note that stage will regenerate the right local and remote paths.
//
if ( (fd = (int)Open_ufs(local_path, Oflag, Mode, popts)) == -ENOENT
&& (popts & XRDEXP_REMOTE))
{if (!(popts & XRDEXP_STAGE))
return OssEroute.Emsg("Open",-XRDOSS_E8006,"open",path);
if ((retc = XrdOssSS->Stage(tident, path, Env, Oflag, Mode, popts)))
return retc;
fd = (int)Open_ufs(local_path, Oflag, Mode, popts & ~XRDEXP_REMOTE);
}
// This interface supports only regular files. Complain if this is not one.
//
if (fd >= 0)
{do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
if (!retc && !(buf.st_mode & S_IFREG))
{close(fd); fd = (buf.st_mode & S_IFDIR ? -EISDIR : -ENOTBLK);}
if ((Oflag & O_ACCMODE) != O_RDONLY)
{FSize = buf.st_size; cacheP = XrdOssCache::Find(local_path);}
else {if (buf.st_mode & XRDSFS_POSCPEND && fd >= 0)
{close(fd); fd=-ETXTBSY;}
FSize = -1; cacheP = 0;
}
} else if (fd == -EEXIST)
{do {retc = stat(local_path,&buf);} while(retc && errno==EINTR);
if (!retc && (buf.st_mode & S_IFDIR)) fd = -EISDIR;
}
// See if should memory map this file. For now, extended attributes are only
// needed when memory mapping is enabled and can apply only to specific files.
// So, we read them here should we need them.
//
if (fd >= 0 && XrdOssSS->tryMmap)
{XrdOucXAttr<XrdFrcXAttrMem> Info;
mopts = 0;
if (!(popts & XRDEXP_NOXATTR) && XrdOssSS->chkMmap)
Info.Get(local_path, fd);
if (popts & XRDEXP_MKEEP || Info.Attr.Flags & XrdFrcXAttrMem::memKeep)
mopts |= OSSMIO_MPRM;
if (popts & XRDEXP_MLOK || Info.Attr.Flags & XrdFrcXAttrMem::memLock)
mopts |= OSSMIO_MLOK;
if (popts & XRDEXP_MMAP || Info.Attr.Flags & XrdFrcXAttrMem::memMap)
mopts |= OSSMIO_MMAP;
if (mopts) mmFile = XrdOssMio::Map(local_path, fd, mopts);
} else mmFile = 0;
// Return the result of this open
//
return (fd < 0 ? fd : XrdOssOK);
}
XrdOssSS
XrdOssSys * XrdOssSS
Definition XrdOssApi.cc:77
XRDOSS_E8006
#define XRDOSS_E8006
Definition XrdOssError.hh:40
XRDOSS_E8003
#define XRDOSS_E8003
Definition XrdOssError.hh:37
XRDOSS_E8005
#define XRDOSS_E8005
Definition XrdOssError.hh:39
OSSMIO_MMAP
#define OSSMIO_MMAP
Definition XrdOssMio.hh:41
OSSMIO_MLOK
#define OSSMIO_MLOK
Definition XrdOssMio.hh:40
OSSMIO_MPRM
#define OSSMIO_MPRM
Definition XrdOssMio.hh:42
XRDEXP_NOTRW
#define XRDEXP_NOTRW
Definition XrdOucExport.hh:45
XRDEXP_MMAP
#define XRDEXP_MMAP
Definition XrdOucExport.hh:56
XRDEXP_MKEEP
#define XRDEXP_MKEEP
Definition XrdOucExport.hh:60
XRDEXP_FORCERO
#define XRDEXP_FORCERO
Definition XrdOucExport.hh:43
XRDEXP_REMOTE
#define XRDEXP_REMOTE
Definition XrdOucExport.hh:85
XRDEXP_MLOK
#define XRDEXP_MLOK
Definition XrdOucExport.hh:58
XRDEXP_NOXATTR
#define XRDEXP_NOXATTR
Definition XrdOucExport.hh:64
XRDEXP_STAGE
#define XRDEXP_STAGE
Definition XrdOucExport.hh:52
XRDSFS_POSCPEND
#define XRDSFS_POSCPEND
Definition XrdSfsFlags.hh:89
XrdFrcXAttrMem::memKeep
static const char memKeep
Definition XrdFrcXAttr.hh:98
XrdFrcXAttrMem::memLock
static const char memLock
Definition XrdFrcXAttr.hh:99
XrdFrcXAttrMem::memMap
static const char memMap
Definition XrdFrcXAttr.hh:97
XrdOssCache::Find
static XrdOssCache_FS * Find(const char *Path, int lklen=0)
Definition XrdOssCache.cc:611
XrdOssMio::Map
static XrdOssMioFile * Map(char *path, int fd, int opts)
Definition XrdOssMio.cc:94
XrdOssSys::Stage
virtual int Stage(const char *, const char *, XrdOucEnv &, int, mode_t, unsigned long long)
Definition XrdOssStage.cc:110
XrdOssSys::chkMmap
static char chkMmap
Definition XrdOssApi.hh:204
XrdOssSys::PathOpts
unsigned long long PathOpts(const char *path)
Definition XrdOssApi.hh:177
XrdOssSys::lcl_N2N
XrdOucName2Name * lcl_N2N
Definition XrdOssApi.hh:254
XrdOssSys::tryMmap
static char tryMmap
Definition XrdOssApi.hh:203
XrdOucName2Name::lfn2pfn
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
TPC::Info
@ Info
Definition XrdHttpTpcTPC.hh:29

References close, XrdOssDF::fd, XrdOssCache::Find(), fstat, XrdOucEnv::Get(), XrdOssMio::Map(), XrdFrcXAttrMem::memKeep, XrdFrcXAttrMem::memLock, XrdFrcXAttrMem::memMap, Mode, OssEroute, OSSMIO_MLOK, OSSMIO_MMAP, OSSMIO_MPRM, stat, XrdOssDF::tident, XRDEXP_FORCERO, XRDEXP_MKEEP, XRDEXP_MLOK, XRDEXP_MMAP, XRDEXP_NOTRW, XRDEXP_NOXATTR, XRDEXP_REMOTE, XRDEXP_STAGE, XRDOSS_E8003, XRDOSS_E8005, XRDOSS_E8006, XrdOssOK, XrdOssSS, and XRDSFS_POSCPEND.

Here is the call graph for this function:

## Read() [1/3]

ssize_t XrdOssFile::Read | ( | off_t | offset,
|  | size_t | size )

virtual

Preread file blocks into the file system cache.

Parameters

  offset | - The offset where the read is to start.
  size | - The number of bytes to pre-read.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 846 of file XrdOssApi.cc.

{
if (fd < 0) return (ssize_t)-XRDOSS_E8004;
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
posix_fadvise(fd, offset, blen, POSIX_FADV_WILLNEED);
#endif
return 0; // We haven't implemented this yet!
}

References XrdOssDF::fd, and XRDOSS_E8004.

Referenced by Read().

Here is the caller graph for this function:

## Read() [2/3]

ssize_t XrdOssFile::Read | ( | void * | buffer,
|  | off_t | offset,
|  | size_t | size )

virtual

Read file bytes into a buffer.

Parameters

  buffer | - pointer to buffer where the bytes are to be placed.
  offset | - The offset where the read is to start.
  size | - The number of bytes to read.

Returns
  >= 0 The number of bytes that placed in buffer.
  < 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 875 of file XrdOssApi.cc.

{
ssize_t retval;
if (fd < 0) return (ssize_t)-XRDOSS_E8004;
#ifdef XRDOSSCX
if (cxobj)
if (XrdOssSS->DirFlags & XrdOssNOSSDEC) return (ssize_t)-XRDOSS_E8021;
else retval = cxobj->Read((char *)buff, blen, offset);
else
#endif
do { retval = pread(fd, buff, blen, offset); }
while(retval < 0 && errno == EINTR);
return (retval >= 0 ? retval : (ssize_t)-errno);
}
XRDOSS_E8021
#define XRDOSS_E8021
Definition XrdOssError.hh:55
pread
#define pread(a, b, c, d)
Definition XrdPosix.hh:80
XrdOssSys::DirFlags
unsigned long long DirFlags
Definition XrdOssApi.hh:244

References XrdOssDF::fd, pread, XRDOSS_E8004, XRDOSS_E8021, and XrdOssSS.

## Read() [3/3]

int XrdOssFile::Read | ( | XrdSfsAio * | aiop | ) |

virtual

Read file bytes using asynchronous I/O.

Parameters

  aiop | - Pointer to async I/O object controlling the I/O.

Returns
  0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 154 of file XrdOssAio.cc.

{
#ifdef _POSIX_ASYNCHRONOUS_IO
EPNAME("AioRead");
int rc;
// Complete the aio request block and do the operation
//
if (XrdOssSys::AioAllOk)
{aiop->sfsAio.aio_fildes = fd;
aiop->sfsAio.aio_sigevent.sigev_signo = OSS_AIO_READ_DONE;
aiop->TIdent = tident;
TRACE(Debug, "fd=" <<fd <<" read " <<aiop->sfsAio.aio_nbytes <<'@'
<<aiop->sfsAio.aio_offset <<" started; aiocb="
<<Xrd::hex1 <<aiop);
// Start the operation
//
if (!(rc = aio_read(&aiop->sfsAio))) return 0;
if (errno != EAGAIN && errno != ENOSYS) return -errno;
// Aio failed keep track of the problem (msg every 1024 events). Note
// that the handling of the counter is sloppy because we do not lock it.
//
{int fcnt = AioFailure++;
if ((fcnt & 0x3ff) == 1) OssEroute.Emsg("aio", errno, "read async");
}
}
#endif
// Execute this request in a synchronous fashion
//
aiop->Result = this->Read((void *)aiop->sfsAio.aio_buf,
(off_t)aiop->sfsAio.aio_offset,
(size_t)aiop->sfsAio.aio_nbytes);
// Simple call the read completion routine and return as if all went well
//
aiop->doneRead();
return 0;
}
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
Debug
bool Debug
Definition XrdSecgsiProxy.cc:95
aiocb::aio_offset
off_t aio_offset
Definition XrdSfsAio.hh:49
aiocb::aio_nbytes
size_t aio_nbytes
Definition XrdSfsAio.hh:48
aiocb::aio_buf
void * aio_buf
Definition XrdSfsAio.hh:47
TRACE
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdOssFile::Read
ssize_t Read(off_t, size_t)
Definition XrdOssApi.cc:846
XrdSfsAio::doneRead
virtual void doneRead()=0
Xrd::hex1
@ hex1
Definition XrdSysTrace.hh:42

References aiocb::aio_buf, aiocb::aio_fildes, aiocb::aio_nbytes, aiocb::aio_offset, aiocb::aio_sigevent, XrdOssSys::AioAllOk, Debug, XrdSfsAio::doneRead(), EPNAME, XrdOssDF::fd, Xrd::hex1, OssEroute, Read(), XrdSfsAio::Result, XrdSfsAio::sfsAio, XrdSfsAio::TIdent, XrdOssDF::tident, and TRACE.

Here is the call graph for this function:

## ReadRaw()

ssize_t XrdOssFile::ReadRaw | ( | void * | buffer,
|  | off_t | offset,
|  | size_t | size )

virtual

Read uncompressed file bytes into a buffer.

Parameters

  buffer | - pointer to buffer where the bytes are to be placed.
  offset | - The offset where the read is to start.
  size | - The number of bytes to read.

Returns
  >= 0 The number of bytes that placed in buffer.
  < 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 991 of file XrdOssApi.cc.

{
ssize_t retval;
if (fd < 0) return (ssize_t)-XRDOSS_E8004;
#ifdef XRDOSSCX
if (cxobj) retval = cxobj->ReadRaw((char *)buff, blen, offset);
else
#endif
do { retval = pread(fd, buff, blen, offset); }
while(retval < 0 && errno == EINTR);
return (retval >= 0 ? retval : (ssize_t)-errno);
}

References XrdOssDF::fd, pread, and XRDOSS_E8004.

## ReadV()

ssize_t XrdOssFile::ReadV | ( | XrdOucIOVec * | readV,
|  | int | rdvcnt )

virtual

Read file bytes as directed by the read vector.

Parameters

  readV | pointer to the array of read requests.
  rdvcnt | the number of elements in readV.

Returns
  >=0 The numbe of bytes read.
  < 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 910 of file XrdOssApi.cc.

{
ssize_t rdsz, totBytes = 0;
int i;
// For platforms that support fadvise, pre-advise what we will be reading
//
#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
EPNAME("ReadV");
long long begOff, endOff, begLst = -1, endLst = -1;
int nPR = n;
// Indicate we are in preread state and see if we have exceeded the limit
//
if (XrdOssSS->prDepth
&& AtomicInc((XrdOssSS->prActive)) < XrdOssSS->prQSize && n > 2)
{int faBytes = 0;
for (nPR=0;nPR < XrdOssSS->prDepth && faBytes < XrdOssSS->prBytes;nPR++)
if (readV[nPR].size > 0)
{begOff = XrdOssSS->prPMask & readV[nPR].offset;
endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
rdsz = endOff - begOff + 1;
if ((begOff > endLst || endOff < begLst)
&& rdsz < XrdOssSS->prBytes)
{posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
faBytes += rdsz;
}
begLst = begOff; endLst = endOff;
}
}
#endif
// Read in the vector and do a pre-advise if we support that
//
for (i = 0; i < n; i++)
{do {rdsz = pread(fd, readV[i].data, readV[i].size, readV[i].offset);}
while(rdsz < 0 && errno == EINTR);
if (rdsz < 0 || rdsz != readV[i].size)
{totBytes = (rdsz < 0 ? -errno : -ESPIPE); break;}
totBytes += rdsz;
#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
if (nPR < n && readV[nPR].size > 0)
{begOff = XrdOssSS->prPMask & readV[nPR].offset;
endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
rdsz = endOff - begOff + 1;
if ((begOff > endLst || endOff < begLst)
&& rdsz <= XrdOssSS->prBytes)
{posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
}
begLst = begOff; endLst = endOff;
}
nPR++;
#endif
}
// All done, return bytes read.
//
#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
if (XrdOssSS->prDepth) AtomicDec((XrdOssSS->prActive));
#endif
return totBytes;
}
AtomicInc
#define AtomicInc(x)
Definition XrdSysAtomics.hh:72
AtomicDec
#define AtomicDec(x)
Definition XrdSysAtomics.hh:68
XrdOssSys::prDepth
short prDepth
Definition XrdOssApi.hh:279
XrdOssSys::prBytes
int prBytes
Definition XrdOssApi.hh:277
XrdOssSys::prQSize
short prQSize
Definition XrdOssApi.hh:280
XrdOssSys::prActive
int prActive
Definition XrdOssApi.hh:278
XrdOssSys::prPMask
long long prPMask
Definition XrdOssApi.hh:275
XrdOssSys::prPBits
long long prPBits
Definition XrdOssApi.hh:274
XrdOucIOVec::size
int size
Definition XrdOucIOVec.hh:43
XrdOucIOVec::offset
long long offset
Definition XrdOucIOVec.hh:42

References AtomicDec, AtomicInc, Debug, EPNAME, XrdOssDF::fd, XrdOucIOVec::offset, pread, XrdOucIOVec::size, TRACE, and XrdOssSS.

## Write() [1/2]

ssize_t XrdOssFile::Write | ( | const void * | buffer,
|  | off_t | offset,
|  | size_t | size )

virtual

Write file bytes from a buffer.

Parameters

  buffer | - pointer to buffer where the bytes reside.
  offset | - The offset where the write is to start.
  size | - The number of bytes to write.

Returns
  >= 0 The number of bytes that were written.
  < 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1022 of file XrdOssApi.cc.

{
ssize_t retval;
if (fd < 0) return (ssize_t)-XRDOSS_E8004;
if (XrdOssSS->MaxSize && (long long)(offset+blen) > XrdOssSS->MaxSize)
return (ssize_t)-XRDOSS_E8007;
do { retval = pwrite(fd, buff, blen, offset); }
while(retval < 0 && errno == EINTR);
if (retval < 0) retval = (retval == EBADF && cxobj ? -XRDOSS_E8022 : -errno);
return retval;
}
XRDOSS_E8007
#define XRDOSS_E8007
Definition XrdOssError.hh:41
XRDOSS_E8022
#define XRDOSS_E8022
Definition XrdOssError.hh:56
pwrite
#define pwrite(a, b, c, d)
Definition XrdPosix.hh:107
XrdOssSys::MaxSize
long long MaxSize
Definition XrdOssApi.hh:241

References XrdOssDF::fd, pwrite, XRDOSS_E8004, XRDOSS_E8007, XRDOSS_E8022, and XrdOssSS.

Referenced by Write().

Here is the caller graph for this function:

## Write() [2/2]

int XrdOssFile::Write | ( | XrdSfsAio * | aiop | ) |

virtual

Write file bytes using asynchronous I/O.

Parameters

  aiop | - Pointer to async I/O object controlling the I/O.

Returns
  0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 212 of file XrdOssAio.cc.

{
#ifdef _POSIX_ASYNCHRONOUS_IO
EPNAME("AioWrite");
int rc;
// Complete the aio request block and do the operation
//
if (XrdOssSys::AioAllOk)
{aiop->sfsAio.aio_fildes = fd;
aiop->sfsAio.aio_sigevent.sigev_signo = OSS_AIO_WRITE_DONE;
aiop->TIdent = tident;
TRACE(Debug, "fd=" <<fd <<" write " <<aiop->sfsAio.aio_nbytes <<'@'
<<aiop->sfsAio.aio_offset <<" started; aiocb="
<<Xrd::hex1 <<aiop);
// Start the operation
//
if (!(rc = aio_write(&aiop->sfsAio))) return 0;
if (errno != EAGAIN && errno != ENOSYS) return -errno;
// Aio failed keep track of the problem (msg every 1024 events). Note
// that the handling of the counter is sloppy because we do not lock it.
//
{int fcnt = AioFailure++;
if ((fcnt & 0x3ff) == 1) OssEroute.Emsg("Write",errno,"write async");
}
}
#endif
// Execute this request in a synchronous fashion
//
aiop->Result = this->Write((const void *)aiop->sfsAio.aio_buf,
(off_t)aiop->sfsAio.aio_offset,
(size_t)aiop->sfsAio.aio_nbytes);
// Simply call the write completion routine and return as if all went well
//
aiop->doneWrite();
return 0;
}
XrdOssFile::Write
ssize_t Write(const void *, off_t, size_t)
Definition XrdOssApi.cc:1022

References aiocb::aio_buf, aiocb::aio_fildes, aiocb::aio_nbytes, aiocb::aio_offset, aiocb::aio_sigevent, XrdOssSys::AioAllOk, Debug, XrdSfsAio::doneWrite(), EPNAME, XrdOssDF::fd, Xrd::hex1, OssEroute, XrdSfsAio::Result, XrdSfsAio::sfsAio, XrdSfsAio::TIdent, XrdOssDF::tident, TRACE, and Write().

Here is the call graph for this function:

The documentation for this class was generated from the following files:

- XrdOssApi.hh
- XrdOssAio.cc
- XrdOssApi.cc