XRootD
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.

118 : XrdOssDF(tid, DF_isFile, fdnum),
119 cxobj(0), cacheP(0), mmFile(0),
120 rawio(0), cxpgsz(0) {cxid[0] = '\0';}
static const uint16_t DF_isFile
Object is for a file.
Definition XrdOss.hh:393
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 ( )
inlinevirtual

Definition at line 122 of file XrdOssApi.hh.

122{if (fd >= 0) Close();}
int fd
Definition XrdOss.hh:455
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
retszIf 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.

814{
815 if (fd < 0) return -XRDOSS_E8004;
816 if (retsz || cacheP)
817 {struct stat buf;
818 int retc;
819 do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
820 if (cacheP && FSize != buf.st_size)
821 XrdOssCache::Adjust(cacheP, buf.st_size - FSize);
822 if (retsz) *retsz = buf.st_size;
823 }
824 if (close(fd)) return -errno;
825 if (mmFile) {XrdOssMio::Recycle(mmFile); mmFile = 0;}
826#ifdef XRDOSSCX
827 if (cxobj) {delete cxobj; cxobj = 0;}
828#endif
829 fd = -1; FSize = -1; cacheP = 0;
830 return XrdOssOK;
831}
#define XRDOSS_E8004
#define XrdOssOK
Definition XrdOss.hh:50
#define close(a)
Definition XrdPosix.hh:48
#define fstat(a, b)
Definition XrdPosix.hh:62
#define stat(a, b)
Definition XrdPosix.hh:101
static void Adjust(dev_t devid, off_t size)
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.

1051{
1052 return (fchmod(fd, Mode) ? -errno : XrdOssOK);
1053}
int Mode

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.

1070{
1071 const struct timeval *utArgs;
1072
1073 switch(cmd)
1075 if (alen != sizeof(struct timeval)*2 || !args) return -EINVAL;
1076 utArgs = (const struct timeval *)args;
1077 if (futimes(fd, utArgs)) return -errno;
1078 return XrdOssOK;
1079 break;
1080 default: break;
1081 }
1082 return -ENOTSUP;
1083}
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.

1096{
1097// This actually only works in Linux so we punt otherwise
1098//
1099#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1100 if (fd>= 0)
1101 {fdatasync(fd);
1102 posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
1103 }
1104#endif
1105}
int fdatasync(int fildes)

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.

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

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.

1136{
1137 return (fsync(fd) ? -errno : XrdOssOK);
1138}
#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.

103{
104
105#ifdef _POSIX_ASYNCHRONOUS_IO
106 int rc;
107
108// Complete the aio request block and do the operation
109//
111 {aiop->sfsAio.aio_fildes = fd;
112 aiop->sfsAio.aio_sigevent.sigev_signo = OSS_AIO_WRITE_DONE;
113 aiop->TIdent = tident;
114
115 // Start the operation
116 //
117 if (!(rc = aio_fsync(O_SYNC, &aiop->sfsAio))) return 0;
118 if (errno != EAGAIN && errno != ENOSYS) return -errno;
119
120 // Aio failed keep track of the problem (msg every 1024 events). Note
121 // that the handling of the counter is sloppy because we do not lock it.
122 //
123 {int fcnt = AioFailure++;
124 if ((fcnt & 0x3ff) == 1) OssEroute.Emsg("aio", errno, "fsync async");
125 }
126 }
127#endif
128
129// Execute this request in a synchronous fashion
130//
131 if ((aiop->Result = Fsync())) aiop->Result = -errno;
132
133// Simply call the write completion routine and return as if all went well
134//
135 aiop->doneWrite();
136 return 0;
137}
XrdSysError OssEroute
struct sigevent aio_sigevent
Definition XrdSfsAio.hh:51
int aio_fildes
Definition XrdSfsAio.hh:46
const char * tident
Definition XrdOss.hh:453
static int AioAllOk
Definition XrdOssApi.hh:201
ssize_t Result
Definition XrdSfsAio.hh:65
const char * TIdent
Definition XrdSfsAio.hh:67
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
virtual void doneWrite()=0
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

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.

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

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

◆ getFD()

int XrdOssFile::getFD ( )
inlinevirtual

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.

105{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.

1155{
1156 if (mmFile) return (addr ? mmFile->Export(addr) : 1);
1157 if (addr) *addr = 0;
1158 return 0;
1159}

◆ 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.

1176{
1177 if (cxpgsz)
1178 {cxidp[0] = cxid[0]; cxidp[1] = cxid[1];
1179 cxidp[2] = cxid[2]; cxidp[3] = cxid[3];
1180 }
1181 return cxpgsz;
1182}

◆ 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.

719{
720 unsigned long long popts;
721 int retc, mopts;
722 char actual_path[MAXPATHLEN+1], *local_path;
723 struct stat buf;
724
725// Return an error if this object is already open
726//
727 if (fd >= 0) return -XRDOSS_E8003;
728 else cxobj = 0;
729
730// Construct the processing options for this path.
731//
732 popts = XrdOssSS->PathOpts(path);
733 if (popts & XRDEXP_STAGE && Env.Get("oss.lcl")) popts &= ~XRDEXP_STAGE;
734
735// Generate local path
736//
737 if (XrdOssSS->lcl_N2N)
738 if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
739 return retc;
740 else local_path = actual_path;
741 else local_path = (char *)path;
742
743// Check if this is a read/only filesystem
744//
745 if (((Oflag & O_ACCMODE) != O_RDONLY) && (popts & XRDEXP_NOTRW))
746 {if (popts & XRDEXP_FORCERO) Oflag = O_RDONLY;
747 else return OssEroute.Emsg("Open",-XRDOSS_E8005,"open r/w",path);
748 }
749
750// If we can open the local copy. If not found, try to stage it in if possible.
751// Note that stage will regenerate the right local and remote paths.
752//
753 if ( (fd = (int)Open_ufs(local_path, Oflag, Mode, popts)) == -ENOENT
754 && (popts & XRDEXP_REMOTE))
755 {if (!(popts & XRDEXP_STAGE))
756 return OssEroute.Emsg("Open",-XRDOSS_E8006,"open",path);
757 if ((retc = XrdOssSS->Stage(tident, path, Env, Oflag, Mode, popts)))
758 return retc;
759 fd = (int)Open_ufs(local_path, Oflag, Mode, popts & ~XRDEXP_REMOTE);
760 }
761
762// This interface supports only regular files. Complain if this is not one.
763//
764 if (fd >= 0)
765 {do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
766 if (!retc && !(buf.st_mode & S_IFREG))
767 {close(fd); fd = (buf.st_mode & S_IFDIR ? -EISDIR : -ENOTBLK);}
768 if ((Oflag & O_ACCMODE) != O_RDONLY)
769 {FSize = buf.st_size; cacheP = XrdOssCache::Find(local_path);}
770 else {if (buf.st_mode & XRDSFS_POSCPEND && fd >= 0)
771 {close(fd); fd=-ETXTBSY;}
772 FSize = -1; cacheP = 0;
773 }
774 } else if (fd == -EEXIST)
775 {do {retc = stat(local_path,&buf);} while(retc && errno==EINTR);
776 if (!retc && (buf.st_mode & S_IFDIR)) fd = -EISDIR;
777 }
778
779// See if should memory map this file. For now, extended attributes are only
780// needed when memory mapping is enabled and can apply only to specific files.
781// So, we read them here should we need them.
782//
783 if (fd >= 0 && XrdOssSS->tryMmap)
784 {XrdOucXAttr<XrdFrcXAttrMem> Info;
785 mopts = 0;
786 if (!(popts & XRDEXP_NOXATTR) && XrdOssSS->chkMmap)
787 Info.Get(local_path, fd);
788 if (popts & XRDEXP_MKEEP || Info.Attr.Flags & XrdFrcXAttrMem::memKeep)
789 mopts |= OSSMIO_MPRM;
790 if (popts & XRDEXP_MLOK || Info.Attr.Flags & XrdFrcXAttrMem::memLock)
791 mopts |= OSSMIO_MLOK;
792 if (popts & XRDEXP_MMAP || Info.Attr.Flags & XrdFrcXAttrMem::memMap)
793 mopts |= OSSMIO_MMAP;
794 if (mopts) mmFile = XrdOssMio::Map(local_path, fd, mopts);
795 } else mmFile = 0;
796
797// Return the result of this open
798//
799 return (fd < 0 ? fd : XrdOssOK);
800}
XrdOssSys * XrdOssSS
Definition XrdOssApi.cc:77
#define XRDOSS_E8006
#define XRDOSS_E8003
#define XRDOSS_E8005
#define OSSMIO_MMAP
Definition XrdOssMio.hh:41
#define OSSMIO_MLOK
Definition XrdOssMio.hh:40
#define OSSMIO_MPRM
Definition XrdOssMio.hh:42
#define XRDEXP_NOTRW
#define XRDEXP_MMAP
#define XRDEXP_MKEEP
#define XRDEXP_FORCERO
#define XRDEXP_REMOTE
#define XRDEXP_MLOK
#define XRDEXP_NOXATTR
#define XRDEXP_STAGE
#define XRDSFS_POSCPEND
static const char memKeep
static const char memLock
static const char memMap
static XrdOssCache_FS * Find(const char *Path, int lklen=0)
static XrdOssMioFile * Map(char *path, int fd, int opts)
Definition XrdOssMio.cc:94
virtual int Stage(const char *, const char *, XrdOucEnv &, int, mode_t, unsigned long long)
static char chkMmap
Definition XrdOssApi.hh:204
unsigned long long PathOpts(const char *path)
Definition XrdOssApi.hh:177
XrdOucName2Name * lcl_N2N
Definition XrdOssApi.hh:254
static char tryMmap
Definition XrdOssApi.hh:203
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0

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.

847{
848
849 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
850
851#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
852 posix_fadvise(fd, offset, blen, POSIX_FADV_WILLNEED);
853#endif
854
855 return 0; // We haven't implemented this yet!
856}

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.

876{
877 ssize_t retval;
878
879 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
880
881#ifdef XRDOSSCX
882 if (cxobj)
883 if (XrdOssSS->DirFlags & XrdOssNOSSDEC) return (ssize_t)-XRDOSS_E8021;
884 else retval = cxobj->Read((char *)buff, blen, offset);
885 else
886#endif
887 do { retval = pread(fd, buff, blen, offset); }
888 while(retval < 0 && errno == EINTR);
889
890 return (retval >= 0 ? retval : (ssize_t)-errno);
891}
#define XRDOSS_E8021
#define pread(a, b, c, d)
Definition XrdPosix.hh:80
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.

155{
156
157#ifdef _POSIX_ASYNCHRONOUS_IO
158 EPNAME("AioRead");
159 int rc;
160
161// Complete the aio request block and do the operation
162//
164 {aiop->sfsAio.aio_fildes = fd;
165 aiop->sfsAio.aio_sigevent.sigev_signo = OSS_AIO_READ_DONE;
166 aiop->TIdent = tident;
167 TRACE(Debug, "fd=" <<fd <<" read " <<aiop->sfsAio.aio_nbytes <<'@'
168 <<aiop->sfsAio.aio_offset <<" started; aiocb="
169 <<Xrd::hex1 <<aiop);
170
171 // Start the operation
172 //
173 if (!(rc = aio_read(&aiop->sfsAio))) return 0;
174 if (errno != EAGAIN && errno != ENOSYS) return -errno;
175
176 // Aio failed keep track of the problem (msg every 1024 events). Note
177 // that the handling of the counter is sloppy because we do not lock it.
178 //
179 {int fcnt = AioFailure++;
180 if ((fcnt & 0x3ff) == 1) OssEroute.Emsg("aio", errno, "read async");
181 }
182 }
183#endif
184
185// Execute this request in a synchronous fashion
186//
187 aiop->Result = this->Read((void *)aiop->sfsAio.aio_buf,
188 (off_t)aiop->sfsAio.aio_offset,
189 (size_t)aiop->sfsAio.aio_nbytes);
190
191// Simple call the read completion routine and return as if all went well
192//
193 aiop->doneRead();
194 return 0;
195}
#define EPNAME(x)
bool Debug
off_t aio_offset
Definition XrdSfsAio.hh:49
size_t aio_nbytes
Definition XrdSfsAio.hh:48
void * aio_buf
Definition XrdSfsAio.hh:47
#define TRACE(act, x)
Definition XrdTrace.hh:63
ssize_t Read(off_t, size_t)
Definition XrdOssApi.cc:846
virtual void doneRead()=0

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.

992{
993 ssize_t retval;
994
995 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
996
997#ifdef XRDOSSCX
998 if (cxobj) retval = cxobj->ReadRaw((char *)buff, blen, offset);
999 else
1000#endif
1001 do { retval = pread(fd, buff, blen, offset); }
1002 while(retval < 0 && errno == EINTR);
1003
1004 return (retval >= 0 ? retval : (ssize_t)-errno);
1005}

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
readVpointer to the array of read requests.
rdvcntthe 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.

911{
912 ssize_t rdsz, totBytes = 0;
913 int i;
914
915// For platforms that support fadvise, pre-advise what we will be reading
916//
917#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
918 EPNAME("ReadV");
919 long long begOff, endOff, begLst = -1, endLst = -1;
920 int nPR = n;
921
922// Indicate we are in preread state and see if we have exceeded the limit
923//
924 if (XrdOssSS->prDepth
925 && AtomicInc((XrdOssSS->prActive)) < XrdOssSS->prQSize && n > 2)
926 {int faBytes = 0;
927 for (nPR=0;nPR < XrdOssSS->prDepth && faBytes < XrdOssSS->prBytes;nPR++)
928 if (readV[nPR].size > 0)
929 {begOff = XrdOssSS->prPMask & readV[nPR].offset;
930 endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
931 rdsz = endOff - begOff + 1;
932 if ((begOff > endLst || endOff < begLst)
933 && rdsz < XrdOssSS->prBytes)
934 {posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
935 TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
936 faBytes += rdsz;
937 }
938 begLst = begOff; endLst = endOff;
939 }
940 }
941#endif
942
943// Read in the vector and do a pre-advise if we support that
944//
945 for (i = 0; i < n; i++)
946 {do {rdsz = pread(fd, readV[i].data, readV[i].size, readV[i].offset);}
947 while(rdsz < 0 && errno == EINTR);
948 if (rdsz < 0 || rdsz != readV[i].size)
949 {totBytes = (rdsz < 0 ? -errno : -ESPIPE); break;}
950 totBytes += rdsz;
951#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
952 if (nPR < n && readV[nPR].size > 0)
953 {begOff = XrdOssSS->prPMask & readV[nPR].offset;
954 endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
955 rdsz = endOff - begOff + 1;
956 if ((begOff > endLst || endOff < begLst)
957 && rdsz <= XrdOssSS->prBytes)
958 {posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
959 TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
960 }
961 begLst = begOff; endLst = endOff;
962 }
963 nPR++;
964#endif
965 }
966
967// All done, return bytes read.
968//
969#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
971#endif
972 return totBytes;
973}
#define AtomicInc(x)
#define AtomicDec(x)
short prDepth
Definition XrdOssApi.hh:279
short prQSize
Definition XrdOssApi.hh:280
long long prPMask
Definition XrdOssApi.hh:275
long long prPBits
Definition XrdOssApi.hh:274
long long offset

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.

1023{
1024 ssize_t retval;
1025
1026 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1027
1028 if (XrdOssSS->MaxSize && (long long)(offset+blen) > XrdOssSS->MaxSize)
1029 return (ssize_t)-XRDOSS_E8007;
1030
1031 do { retval = pwrite(fd, buff, blen, offset); }
1032 while(retval < 0 && errno == EINTR);
1033
1034 if (retval < 0) retval = (retval == EBADF && cxobj ? -XRDOSS_E8022 : -errno);
1035 return retval;
1036}
#define XRDOSS_E8007
#define XRDOSS_E8022
#define pwrite(a, b, c, d)
Definition XrdPosix.hh:107
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.

213{
214#ifdef _POSIX_ASYNCHRONOUS_IO
215 EPNAME("AioWrite");
216 int rc;
217
218// Complete the aio request block and do the operation
219//
221 {aiop->sfsAio.aio_fildes = fd;
222 aiop->sfsAio.aio_sigevent.sigev_signo = OSS_AIO_WRITE_DONE;
223 aiop->TIdent = tident;
224 TRACE(Debug, "fd=" <<fd <<" write " <<aiop->sfsAio.aio_nbytes <<'@'
225 <<aiop->sfsAio.aio_offset <<" started; aiocb="
226 <<Xrd::hex1 <<aiop);
227
228 // Start the operation
229 //
230 if (!(rc = aio_write(&aiop->sfsAio))) return 0;
231 if (errno != EAGAIN && errno != ENOSYS) return -errno;
232
233 // Aio failed keep track of the problem (msg every 1024 events). Note
234 // that the handling of the counter is sloppy because we do not lock it.
235 //
236 {int fcnt = AioFailure++;
237 if ((fcnt & 0x3ff) == 1) OssEroute.Emsg("Write",errno,"write async");
238 }
239 }
240#endif
241
242// Execute this request in a synchronous fashion
243//
244 aiop->Result = this->Write((const void *)aiop->sfsAio.aio_buf,
245 (off_t)aiop->sfsAio.aio_offset,
246 (size_t)aiop->sfsAio.aio_nbytes);
247
248// Simply call the write completion routine and return as if all went well
249//
250 aiop->doneWrite();
251 return 0;
252}
ssize_t Write(const void *, off_t, size_t)

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: