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 ()
int Clone (const std::vector< XrdOucCloneSeg > &cVec)
int Clone (XrdOssDF &srcFile)
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 bool getErrMsg (std::string &eText)
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 ssize_t Read (XrdOucRangeList &rlist)
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_QFinfo = 3
static const int Fctl_setFD = 2
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 89 of file XrdOssApi.hh.

Constructor & Destructor Documentation

◆ XrdOssFile()

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

Definition at line 122 of file XrdOssApi.hh.

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

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

Here is the call graph for this function:

◆ ~XrdOssFile()

virtual XrdOssFile::~XrdOssFile ( )
inlinevirtual

Definition at line 128 of file XrdOssApi.hh.

128{if (fd >= 0) Close();}
int fd
Definition XrdOss.hh:515
virtual int Close(long long *retsz=0)
Definition XrdOssApi.cc:912

References Close(), and XrdOssDF::fd.

Here is the call graph for this function:

Member Function Documentation

◆ Clone() [1/2]

int XrdOssFile::Clone ( const std::vector< XrdOucCloneSeg > & cVec)
virtual

Clone contents of a file from one or more oher files.

Parameters
cVec- A vector of struct XrdOucCloneSeg describing the action.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 293 of file XrdOssApi.cc.

294{
295#if defined(FICLONERANGE)
296 if (!canClone)
297 return -EPERM;
298
299 if (fd<0)
300 return -EBADF;
301
302 for(auto &seg: cVec)
303 {struct file_clone_range fr;
304 fr.src_fd = seg.srcFD;
305 fr.src_offset = seg.srcOffs;
306 fr.src_length = seg.srcLen;
307 fr.dest_offset = seg.dstOffs;
308 if (ioctl(fd, FICLONERANGE, &fr) == -1) return -errno;
309 }
310
311 return XrdOssOK;
312#else
313 return -ENOTSUP;
314#endif
315}
#define XrdOssOK
Definition XrdOss.hh:54

References XrdOssDF::fd, and XrdOssOK.

◆ Clone() [2/2]

int XrdOssFile::Clone ( XrdOssDF & srcFile)
virtual

Clone contents of a file from another file.

Parameters
srcFile- Reference to the file to used to clone contents of this file.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 273 of file XrdOssApi.cc.

274{
275#if defined(FICLONE)
276 if (!canClone)
277 return -EPERM;
278
279 if (fd<0)
280 return -EBADF;
281 if (srcFile.getFD() < 0)
282 return -EBADF;
283
284 if (ioctl(fd, FICLONE, srcFile.getFD())==-1)
285 return -errno;
286
287 return XrdOssOK;
288#else
289 return -ENOTSUP;
290#endif
291}
virtual int getFD()
Definition XrdOss.hh:486

References XrdOssDF::XrdOssDF(), XrdOssDF::fd, XrdOssDF::getFD(), and XrdOssOK.

Here is the call graph for this function:

◆ 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 912 of file XrdOssApi.cc.

913{
914 if (fd < 0) return -XRDOSS_E8004;
915 if (retsz || cacheP)
916 {struct stat buf;
917 int retc;
918 do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
919 if (cacheP && FSize != buf.st_size)
920 XrdOssCache::Adjust(cacheP, buf.st_size - FSize);
921 if (retsz) *retsz = buf.st_size;
922 }
923 if (close(fd)) return -errno;
924 if (mmFile) {XrdOssMio::Recycle(mmFile); mmFile = 0;}
925#ifdef XRDOSSCX
926 if (cxobj) {delete cxobj; cxobj = 0;}
927#endif
928 fd = -1; FSize = -1; cacheP = 0;
929 return XrdOssOK;
930}
#define XRDOSS_E8004
#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 1149 of file XrdOssApi.cc.

1150{
1151 return (fchmod(fd, Mode) ? -errno : XrdOssOK);
1152}
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 1168 of file XrdOssApi.cc.

1169{
1170 const struct timeval *utArgs;
1171
1172 switch(cmd)
1174 if (alen != sizeof(struct timeval)*2 || !args) return -EINVAL;
1175 utArgs = (const struct timeval *)args;
1176 if (futimes(fd, utArgs)) return -errno;
1177 return XrdOssOK;
1178 break;
1180 if (dfType != DF_isFile) return -ENOTBLK;
1181 if (fd >= 0) return -EALREADY;
1182 if (alen != (int)sizeof(int)) return -EINVAL;
1183 int retc, newFD;
1184 memcpy(&newFD, args, sizeof(int));
1185 struct stat buf;
1186 do {retc = fstat(newFD, &buf);} while(retc && errno == EINTR);
1187 if (retc) return -errno;
1188 fd = newFD;
1189 FSize = buf.st_size;
1190 return XrdOssOK;
1191 break;
1192 default: break;
1193 }
1194 return -ENOTSUP;
1195}
uint16_t dfType
Definition XrdOss.hh:516
static const int Fctl_utimes
Definition XrdOss.hh:459
static const int Fctl_setFD
Definition XrdOss.hh:460

References XrdOssDF::DF_isFile, XrdOssDF::dfType, XrdOssDF::Fctl_setFD, XrdOssDF::Fctl_utimes, XrdOssDF::fd, fstat, stat, and XrdOssOK.

◆ Flush()

void XrdOssFile::Flush ( )
virtual

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

Reimplemented from XrdOssDF.

Definition at line 1207 of file XrdOssApi.cc.

1208{
1209// This actually only works in Linux so we punt otherwise
1210//
1211#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1212 if (fd>= 0)
1213 {fdatasync(fd);
1214 posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
1215 }
1216#endif
1217}
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 1231 of file XrdOssApi.cc.

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

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 1247 of file XrdOssApi.cc.

1248{
1249 return (fsync(fd) ? -errno : XrdOssOK);
1250}
#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:513
static int AioAllOk
Definition XrdOssApi.hh:208
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 1318 of file XrdOssApi.cc.

1318 {
1319 off_t newlen = flen;
1320
1321 if (sizeof(newlen) < sizeof(flen) && (flen>>31)) return -XRDOSS_E8008;
1322
1323// Note that space adjustment will occur when the file is closed, not here
1324//
1325 return (ftruncate(fd, newlen) ? -errno : XrdOssOK);
1326 }
#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 110 of file XrdOssApi.hh.

110{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 1266 of file XrdOssApi.cc.

1267{
1268 if (mmFile) return (addr ? mmFile->Export(addr) : 1);
1269 if (addr) *addr = 0;
1270 return 0;
1271}

◆ 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 1287 of file XrdOssApi.cc.

1288{
1289 if (cxpgsz)
1290 {cxidp[0] = cxid[0]; cxidp[1] = cxid[1];
1291 cxidp[2] = cxid[2]; cxidp[3] = cxid[3];
1292 }
1293 return cxpgsz;
1294}

◆ 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 816 of file XrdOssApi.cc.

817{
818 unsigned long long popts;
819 int retc, mopts;
820 char actual_path[MAXPATHLEN+1], *local_path;
821 struct stat buf;
822
823// Return an error if this object is already open
824//
825 if (fd >= 0) return -XRDOSS_E8003;
826 else cxobj = 0;
827
828// Construct the processing options for this path.
829//
830 popts = XrdOssSS->PathOpts(path);
831 if (popts & XRDEXP_STAGE && Env.Get("oss.lcl")) popts &= ~XRDEXP_STAGE;
832
833// Generate local path
834//
835 if (XrdOssSS->lcl_N2N)
836 if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
837 return retc;
838 else local_path = actual_path;
839 else local_path = (char *)path;
840
841// Check if this is a read/only filesystem
842//
843 if (((Oflag & O_ACCMODE) != O_RDONLY) && (popts & XRDEXP_NOTRW))
844 {if (popts & XRDEXP_FORCERO) Oflag = O_RDONLY;
845 else return OssEroute.Emsg("Open",-XRDOSS_E8005,"open r/w",path);
846 }
847
848// If we can open the local copy. If not found, try to stage it in if possible.
849// Note that stage will regenerate the right local and remote paths.
850//
851 if ( (fd = (int)Open_ufs(local_path, Oflag, Mode, popts)) == -ENOENT
852 && (popts & XRDEXP_REMOTE))
853 {if (!(popts & XRDEXP_STAGE))
854 return OssEroute.Emsg("Open",-XRDOSS_E8006,"open",path);
855 if ((retc = XrdOssSS->Stage(tident, path, Env, Oflag, Mode, popts)))
856 return retc;
857 fd = (int)Open_ufs(local_path, Oflag, Mode, popts & ~XRDEXP_REMOTE);
858 }
859
860// This interface supports only regular files. Complain if this is not one.
861//
862 if (fd >= 0)
863 {do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
864 if (!retc && !(buf.st_mode & S_IFREG))
865 {close(fd); fd = (buf.st_mode & S_IFDIR ? -EISDIR : -ENOTBLK);}
866 if ((Oflag & O_ACCMODE) != O_RDONLY)
867 {FSize = buf.st_size; cacheP = XrdOssCache::Find(local_path);}
868 else {if (buf.st_mode & XRDSFS_POSCPEND && fd >= 0)
869 {close(fd); fd=-ETXTBSY;}
870 FSize = -1; cacheP = 0;
871 }
872 } else if (fd == -EEXIST)
873 {do {retc = stat(local_path,&buf);} while(retc && errno==EINTR);
874 if (!retc && (buf.st_mode & S_IFDIR)) fd = -EISDIR;
875 }
876
877// See if should memory map this file. For now, extended attributes are only
878// needed when memory mapping is enabled and can apply only to specific files.
879// So, we read them here should we need them.
880//
881 if (fd >= 0 && XrdOssSS->tryMmap)
882 {XrdOucXAttr<XrdFrcXAttrMem> Info;
883 mopts = 0;
884 if (!(popts & XRDEXP_NOXATTR) && XrdOssSS->chkMmap)
885 Info.Get(local_path, fd);
886 if (popts & XRDEXP_MKEEP || Info.Attr.Flags & XrdFrcXAttrMem::memKeep)
887 mopts |= OSSMIO_MPRM;
888 if (popts & XRDEXP_MLOK || Info.Attr.Flags & XrdFrcXAttrMem::memLock)
889 mopts |= OSSMIO_MLOK;
890 if (popts & XRDEXP_MMAP || Info.Attr.Flags & XrdFrcXAttrMem::memMap)
891 mopts |= OSSMIO_MMAP;
892 if (mopts) mmFile = XrdOssMio::Map(local_path, fd, mopts);
893 } else mmFile = 0;
894
895 canClone = !(popts & XRDEXP_NOFICL);
896// Return the result of this open
897//
898 return (fd < 0 ? fd : XrdOssOK);
899}
XrdOssSys * XrdOssSS
Definition XrdOssApi.cc:82
#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_NOFICL
#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:211
unsigned long long PathOpts(const char *path)
Definition XrdOssApi.hh:184
XrdOucName2Name * lcl_N2N
Definition XrdOssApi.hh:261
static char tryMmap
Definition XrdOssApi.hh:210
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_NOFICL, 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 When 0, the request was ignored; otherwise, it has been accepted.
< 0 Failed with -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 945 of file XrdOssApi.cc.

946{
947
948 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
949
950#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
951 posix_fadvise(fd, offset, blen, POSIX_FADV_WILLNEED);
952#endif
953
954 return 0; // We haven't implemented this yet!
955}

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 974 of file XrdOssApi.cc.

975{
976 ssize_t retval;
977
978 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
979
980#ifdef XRDOSSCX
981 if (cxobj)
982 if (XrdOssSS->DirFlags & XrdOssNOSSDEC) return (ssize_t)-XRDOSS_E8021;
983 else retval = cxobj->Read((char *)buff, blen, offset);
984 else
985#endif
986 do { retval = pread(fd, buff, blen, offset); }
987 while(retval < 0 && errno == EINTR);
988
989 return (retval >= 0 ? retval : (ssize_t)-errno);
990}
#define XRDOSS_E8021
#define pread(a, b, c, d)
Definition XrdPosix.hh:80
unsigned long long DirFlags
Definition XrdOssApi.hh:251

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:945
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 1090 of file XrdOssApi.cc.

1091{
1092 ssize_t retval;
1093
1094 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1095
1096#ifdef XRDOSSCX
1097 if (cxobj) retval = cxobj->ReadRaw((char *)buff, blen, offset);
1098 else
1099#endif
1100 do { retval = pread(fd, buff, blen, offset); }
1101 while(retval < 0 && errno == EINTR);
1102
1103 return (retval >= 0 ? retval : (ssize_t)-errno);
1104}

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 1009 of file XrdOssApi.cc.

1010{
1011 ssize_t rdsz, totBytes = 0;
1012 int i;
1013
1014// For platforms that support fadvise, pre-advise what we will be reading
1015//
1016#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
1017 EPNAME("ReadV");
1018 long long begOff, endOff, begLst = -1, endLst = -1;
1019 int nPR = n;
1020
1021// Indicate we are in preread state and see if we have exceeded the limit
1022//
1023 if (XrdOssSS->prDepth
1024 && AtomicInc((XrdOssSS->prActive)) < XrdOssSS->prQSize && n > 2)
1025 {int faBytes = 0;
1026 for (nPR=0;nPR < XrdOssSS->prDepth && faBytes < XrdOssSS->prBytes;nPR++)
1027 if (readV[nPR].size > 0)
1028 {begOff = XrdOssSS->prPMask & readV[nPR].offset;
1029 endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
1030 rdsz = endOff - begOff + 1;
1031 if ((begOff > endLst || endOff < begLst)
1032 && rdsz < XrdOssSS->prBytes)
1033 {posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
1034 TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
1035 faBytes += rdsz;
1036 }
1037 begLst = begOff; endLst = endOff;
1038 }
1039 }
1040#endif
1041
1042// Read in the vector and do a pre-advise if we support that
1043//
1044 for (i = 0; i < n; i++)
1045 {do {rdsz = pread(fd, readV[i].data, readV[i].size, readV[i].offset);}
1046 while(rdsz < 0 && errno == EINTR);
1047 if (rdsz < 0 || rdsz != readV[i].size)
1048 {totBytes = (rdsz < 0 ? -errno : -ESPIPE); break;}
1049 totBytes += rdsz;
1050#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
1051 if (nPR < n && readV[nPR].size > 0)
1052 {begOff = XrdOssSS->prPMask & readV[nPR].offset;
1053 endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
1054 rdsz = endOff - begOff + 1;
1055 if ((begOff > endLst || endOff < begLst)
1056 && rdsz <= XrdOssSS->prBytes)
1057 {posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
1058 TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
1059 }
1060 begLst = begOff; endLst = endOff;
1061 }
1062 nPR++;
1063#endif
1064 }
1065
1066// All done, return bytes read.
1067//
1068#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
1070#endif
1071 return totBytes;
1072}
#define AtomicInc(x)
#define AtomicDec(x)
short prDepth
Definition XrdOssApi.hh:286
short prQSize
Definition XrdOssApi.hh:287
long long prPMask
Definition XrdOssApi.hh:282
long long prPBits
Definition XrdOssApi.hh:281
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 1121 of file XrdOssApi.cc.

1122{
1123 ssize_t retval;
1124
1125 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1126
1127 if (XrdOssSS->MaxSize && (long long)(offset+blen) > XrdOssSS->MaxSize)
1128 return (ssize_t)-XRDOSS_E8007;
1129
1130 do { retval = pwrite(fd, buff, blen, offset); }
1131 while(retval < 0 && errno == EINTR);
1132
1133 if (retval < 0) retval = (retval == EBADF && cxobj ? -XRDOSS_E8022 : -errno);
1134 return retval;
1135}
#define XRDOSS_E8007
#define XRDOSS_E8022
#define pwrite(a, b, c, d)
Definition XrdPosix.hh:107
long long MaxSize
Definition XrdOssApi.hh:248

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: