XRootD
Loading...
Searching...
No Matches
XrdPosixExtra Class Reference

Extended POSIX interface to XRootD. More...

#include <XrdPosixExtra.hh>

+ Collaboration diagram for XrdPosixExtra:

Public Member Functions

 XrdPosixExtra ()
 
 ~XrdPosixExtra ()
 

Static Public Member Functions

static ssize_t pgRead (int fildes, void *buffer, off_t offset, size_t rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, XrdPosixCallBackIO *cbp=0)
 
static ssize_t pgWrite (int fildes, void *buffer, off_t offset, size_t wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, XrdPosixCallBackIO *cbp=0)
 

Static Public Attributes

static const uint64_t forceCS = 0x0000000000000001ULL
 

Detailed Description

Extended POSIX interface to XRootD.

Definition at line 46 of file XrdPosixExtra.hh.

Constructor & Destructor Documentation

◆ XrdPosixExtra()

XrdPosixExtra::XrdPosixExtra ( )
inline

Definition at line 97 of file XrdPosixExtra.hh.

97{}

◆ ~XrdPosixExtra()

XrdPosixExtra::~XrdPosixExtra ( )
inline

Definition at line 98 of file XrdPosixExtra.hh.

98{}

Member Function Documentation

◆ pgRead()

ssize_t XrdPosixExtra::pgRead ( int fildes,
void * buffer,
off_t offset,
size_t rdlen,
std::vector< uint32_t > & csvec,
uint64_t opts = 0,
XrdPosixCallBackIO * cbp = 0 )
static

Definition at line 46 of file XrdPosixExtra.cc.

51{
52 XrdPosixFile *fp;
53 long long offs, bytes;
54 uint64_t fOpts;
55 int iosz;
56
57// Find the file object
58//
59 if (!(fp = XrdPosixObject::File(fildes)))
60 {if (!cbp) return -1;
61 cbp->Complete(-1);
62 return 0;
63 }
64
65// Make sure the size is not too large
66//
67 if (rdlen > (size_t)0x7fffffff)
68 {fp->UnLock();
69
70 errno = EOVERFLOW;
71 if (!cbp) return -1;
72 cbp->Complete(-1);
73 return 0;
74 }
75
76// Get the parameters
77//
78 iosz = static_cast<int>(rdlen);
79 offs = static_cast<long long>(offset);
80 csvec.clear();
81 fOpts= (opts & forceCS ? XrdOucCacheIO::forceCS : 0);
82
83// Issue the read in the sync case
84//
85 if (!cbp)
86 {bytes = fp->XCio->pgRead((char *)buffer, offs, (int)iosz, csvec, fOpts);
87 if (bytes < 0)
88 {fp->ecMsg.SetErrno(-bytes);
89 fp->UnLock();
90 return -1;
91 }
92 fp->UnLock();
93 return (ssize_t)bytes;
94 }
95
96// Handle the read in the async case
97//
98 cbp->theFile = fp;
99 fp->Ref(); fp->UnLock();
100
101// Issue the read
102//
103 fp->XCio->pgRead(*cbp, (char *)buffer, offs, (int)iosz, csvec, fOpts);
104 return 0;
105}
struct myOpts opts
static const uint64_t forceCS
virtual int pgRead(char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
int SetErrno(int ecc, int ret=-1, const char *alt=0)
virtual void Complete(ssize_t Result)=0
static const uint64_t forceCS
XrdOucCacheIO * XCio
XrdOucECMsg ecMsg
static XrdPosixFile * File(int fildes, bool glk=false)

References XrdPosixCallBackIO::Complete(), XrdPosixObject::ecMsg, XrdPosixObject::File(), XrdOucCacheIO::forceCS, forceCS, opts, XrdOucCacheIO::pgRead(), XrdPosixObject::Ref(), XrdOucECMsg::SetErrno(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::pgRead(), and XrdPssFile::pgRead().

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

◆ pgWrite()

ssize_t XrdPosixExtra::pgWrite ( int fildes,
void * buffer,
off_t offset,
size_t wrlen,
std::vector< uint32_t > & csvec,
uint64_t opts = 0,
XrdPosixCallBackIO * cbp = 0 )
static

Write file pages into a file with corresponding checksums.

Parameters
fildes- File descriptor
buffer- pointer to buffer containing the bytes to write.
offset- The offset where the write is to start.
wrlen- The number of bytes to write. be the last write to the file at or above the offset.
csvec- A vector which contains the corresponding CRC32 checksum for each page or page segment. If size is 0, then checksums are calculated. If not zero, the size must equal the required number of checksums for offset/wrlen.
opts- Options as noted.
cbp- When supplied, return is made via callback.
Returns
>= 0 Sync: The number of bytes written upon success. Async: Always returns 0.
< 0 errno hold reason for failure.

Definition at line 111 of file XrdPosixExtra.cc.

116{
117 XrdPosixFile *fp;
118 long long offs;
119 int iosz, bytes;
120
121// Find the file object
122//
123 if (!(fp = XrdPosixObject::File(fildes)))
124 {if (!cbp) return -1;
125 cbp->Complete(-1);
126 return 0;
127 }
128
129// Make sure the size is not too large
130//
131 if (wrlen > (size_t)0x7fffffff)
132 {fp->UnLock();
133 errno = EOVERFLOW;
134 if (!cbp) return -1;
135 cbp->Complete(-1);
136 return 0;
137 }
138
139// Check if we need to generate checksums or verify that we have the right num.
140//
141 if (csvec.size() == 0)
142 XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, csvec);
143 else if (XrdOucPgrwUtils::csNum(offset, wrlen) != (int)csvec.size())
144 {fp->UnLock();
145 errno = EINVAL;
146 if (!cbp) return -1;
147 cbp->Complete(-1);
148 return 0;
149 }
150
151// Get the parameters
152//
153 iosz = static_cast<int>(wrlen);
154 offs = static_cast<long long>(offset);
155
156// Sync: Issue the write
157//
158 if (!cbp)
159 {bytes = fp->XCio->pgWrite((char *)buffer, offs, (int)iosz, csvec);
160 if (bytes < 0)
161 {fp->ecMsg.SetErrno(-bytes);
162 fp->UnLock();
163 return -1;
164 }
165 fp->UpdtSize(offs + iosz);
166 fp->UnLock();
167 return (ssize_t)bytes;
168 }
169
170// Async: Prepare for writing
171//
172 cbp->theFile = fp;
173 fp->Ref(); fp->UnLock();
174
175// Issue the write
176//
177 fp->XCio->pgWrite(*cbp, (char *)buffer, offs, (int)iosz, csvec);
178 return 0;
179}
virtual int pgWrite(char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
void UpdtSize(size_t newsz)

References XrdPosixCallBackIO::Complete(), XrdOucPgrwUtils::csCalc(), XrdOucPgrwUtils::csNum(), XrdPosixObject::ecMsg, XrdPosixObject::File(), opts, XrdOucCacheIO::pgWrite(), XrdPosixObject::Ref(), XrdOucECMsg::SetErrno(), XrdPosixObject::UnLock(), XrdPosixFile::UpdtSize(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::pgWrite(), and XrdPssFile::pgWrite().

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

Member Data Documentation

◆ forceCS

const uint64_t XrdPosixExtra::forceCS = 0x0000000000000001ULL
static

Read file pages into a buffer and return corresponding checksums.

Parameters
fildes- File descriptor
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
rdlen- The number of bytes to read.
csvec- A vector to be filled with the corresponding CRC32C checksums for each page or page segment, if available.
opts- Options as noted.
cbp- Async version: return is made via callback.
Returns
>= 0 Sync: Number of bytes that placed in buffer upon success; Async: Always returns 0.
< 0 errno hold reason for failure.

Definition at line 67 of file XrdPosixExtra.hh.

Referenced by pgRead(), XrdPssFile::pgRead(), and XrdPssFile::pgRead().


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