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 int Fctl (int fildes, XrdOucCacheOp::Code opc, const std::string &args, std::string &resp)
static int FSctl (XrdOucCacheOp::Code opc, const std::string &args, std::string &resp, bool viaCache=false, bool viaRedir=false)
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 int PreRead (int fildes, off_t offs, int size)
static int PreRead (int fildes, XrdOucRangeList &rlist)

Static Public Attributes

static const uint64_t forceCS = 0x0000000000000001ULL

Detailed Description

Extended POSIX interface to XRootD.

Definition at line 49 of file XrdPosixExtra.hh.

Constructor & Destructor Documentation

◆ XrdPosixExtra()

XrdPosixExtra::XrdPosixExtra ( )
inline

Definition at line 171 of file XrdPosixExtra.hh.

171{}

◆ ~XrdPosixExtra()

XrdPosixExtra::~XrdPosixExtra ( )
inline

Definition at line 172 of file XrdPosixExtra.hh.

172{}

Member Function Documentation

◆ Fctl()

int XrdPosixExtra::Fctl ( int fildes,
XrdOucCacheOp::Code opc,
const std::string & args,
std::string & resp )
static

Perform file oriented control operation (i.e. a query).

Parameters
fildes- Posix file descriptor of associated file.
opc- The requested operation (e.g. QFinfo).
args- The arguments (this is not necessarily a URL)
resp- Where the result is to be placed.
Returns
>= 0 - Success, resp holds the response data.
< 0 errno hold reason for failure.
Note
This call is routed via the cache if file is cache enabled using the associated CacheIO object returned by the cache attach call..

Definition at line 62 of file XrdPosixExtra.cc.

64{
65 XrdPosixFile *fp;
66
67// Make s
68
69// Execute the request (this handles simple cases)
70//
71 switch(opc)
73 if (!(fp = XrdPosixObject::File(fildes)))
74 {resp = "Invalid file descriptor.";
75 return -1;
76 }
77 break;
78 default:
79 resp = "File operation not supported.";
80 errno = ENOTSUP;
81 return -1;
82 }
83
84// Execute the operation which may first hit the cache if we have one.
85//
86 return fp->XCio->Fcntl(XrdOucCacheOp::Code::QFinfo, args, resp);
87}
virtual int Fcntl(XrdOucCacheOp::Code opc, const std::string &args, std::string &resp)
XrdOucCacheIO * XCio
static XrdPosixFile * File(int fildes, bool glk=false)

References XrdOucCacheIO::Fcntl(), XrdPosixObject::File(), XrdOucCacheOp::QFinfo, and XrdPosixFile::XCio.

Referenced by XrdPssFile::Fctl().

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

◆ FSctl()

int XrdPosixExtra::FSctl ( XrdOucCacheOp::Code opc,
const std::string & args,
std::string & resp,
bool viaCache = false,
bool viaRedir = false )
static

Perform file system oriented control operation (i.e. a query).

Parameters
opc- The requested operation (e.g. QFSinfo).
args- The arguments (this should be a URL).
resp- Where the result is to be placed.
viaCache-False -> Bypass calling any cache using URL in args. True -> Use Cache object API if cache enabled. Otherwise, assume viaCache is false;
viaRedir-False -> Send request directly to endpoint. True -> If endpoint is a redirector, send request to the redirected endpoint (i.e. via redirect)
Returns
>= 0 - Success, resp holds the response data.
< 0 errno hold reason for failure.

Definition at line 93 of file XrdPosixExtra.cc.

96{
98
99// Make sure we support the operation
100//
101 switch(opc)
104 break;
105 default:
106 resp = "Filesystem operation not supported.";
107 errno = ENOTSUP;
108 return -1;
109 }
110
111// Use cache, if possible and allowed, to handle this operation
112//
113 if (viaCache && XrdPosixGlobals::theCache)
114 return XrdPosixGlobals::theCache->Fcntl(opc, args, resp);
115
116// We need to execute this at the endpoint described by args (i.e. a URL)
117//
118 XrdPosixAdmin admin(args.c_str(),XrdPosixGlobals::ecMsg);
119
120// Stat the file first to allow vectoring of the request to the right server
121// but do so only if caller wishes to use a redirect as opposed to sending
122// the request to the actual redirector.
123//
124 if (viaRedir && !admin.Stat()) return -1;
125
126// Return the actual retult
127
128 return admin.Query(clOp, resp);
129}
virtual int Fcntl(XrdOucCacheOp::Code opc, const std::string &args, std::string &resp)
XrdOucECMsg ecMsg
XrdOucCache * theCache
Code
XRootD query request codes.
@ FSInfo
Query op-dependant file information on FS path.

References XrdPosixGlobals::ecMsg, XrdCl::QueryCode::FSInfo, XrdOucCacheOp::QFSinfo, XrdPosixAdmin::Query(), XrdPosixAdmin::Stat(), and XrdPosixGlobals::theCache.

Referenced by XrdPssSys::FSctl().

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

◆ 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 135 of file XrdPosixExtra.cc.

140{
141 XrdPosixFile *fp;
142 long long offs, bytes;
143 uint64_t fOpts;
144 int iosz;
145
146// Find the file object
147//
148 if (!(fp = XrdPosixObject::File(fildes)))
149 {if (!cbp) return -1;
150 cbp->Complete(-1);
151 return 0;
152 }
153
154// Make sure the size is not too large
155//
156 if (rdlen > (size_t)0x7fffffff)
157 {fp->UnLock();
158 errno = EOVERFLOW;
159 if (!cbp) return -1;
160 cbp->Complete(-1);
161 return 0;
162 }
163
164// Get the parameters
165//
166 iosz = static_cast<int>(rdlen);
167 offs = static_cast<long long>(offset);
168 csvec.clear();
169 fOpts= (opts & forceCS ? XrdOucCacheIO::forceCS : 0);
170
171// Issue the read in the sync case
172//
173 if (!cbp)
174 {bytes = fp->XCio->pgRead((char *)buffer, offs, (int)iosz, csvec, fOpts);
175 if (bytes < 0)
176 {fp->ecMsg.SetErrno(-bytes);
177 fp->UnLock();
178 return -1;
179 }
180 fp->UnLock();
181 return (ssize_t)bytes;
182 }
183
184// Handle the read in the async case
185//
186 cbp->theFile = fp;
187 fp->Ref(); fp->UnLock();
188
189// Issue the read
190//
191 fp->XCio->pgRead(*cbp, (char *)buffer, offs, (int)iosz, csvec, fOpts);
192 return 0;
193}
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
XrdOucECMsg ecMsg

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 199 of file XrdPosixExtra.cc.

204{
205 XrdPosixFile *fp;
206 long long offs;
207 int iosz, bytes;
208
209// Find the file object
210//
211 if (!(fp = XrdPosixObject::File(fildes)))
212 {if (!cbp) return -1;
213 cbp->Complete(-1);
214 return 0;
215 }
216
217// Make sure the size is not too large
218//
219 if (wrlen > (size_t)0x7fffffff)
220 {fp->UnLock();
221 errno = EOVERFLOW;
222 if (!cbp) return -1;
223 cbp->Complete(-1);
224 return 0;
225 }
226
227// Check if we need to generate checksums or verify that we have the right num.
228//
229 if (csvec.size() == 0)
230 XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, csvec);
231 else if (XrdOucPgrwUtils::csNum(offset, wrlen) != (int)csvec.size())
232 {fp->UnLock();
233 errno = EINVAL;
234 if (!cbp) return -1;
235 cbp->Complete(-1);
236 return 0;
237 }
238
239// Get the parameters
240//
241 iosz = static_cast<int>(wrlen);
242 offs = static_cast<long long>(offset);
243
244// Sync: Issue the write
245//
246 if (!cbp)
247 {bytes = fp->XCio->pgWrite((char *)buffer, offs, (int)iosz, csvec);
248 if (bytes < 0)
249 {fp->ecMsg.SetErrno(-bytes);
250 fp->UnLock();
251 return -1;
252 }
253 fp->UpdtSize(offs + iosz);
254 fp->UnLock();
255 return (ssize_t)bytes;
256 }
257
258// Async: Prepare for writing
259//
260 cbp->theFile = fp;
261 fp->Ref(); fp->UnLock();
262
263// Issue the write
264//
265 fp->XCio->pgWrite(*cbp, (char *)buffer, offs, (int)iosz, csvec);
266 return 0;
267}
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:

◆ PreRead() [1/2]

int XrdPosixExtra::PreRead ( int fildes,
off_t offs,
int size )
static

Preread a range of bytes.

Parameters
fildes- File descriptor The file descriptor must refer to an open file.
offs- The offset at which to start the preread.
size- The numbert of bytes to preread.
Returns
0 Request accepted.
< 0 Request rejected, errno hold reason for failure.

Definition at line 273 of file XrdPosixExtra.cc.

274{
275 XrdPosixFile *fp;
276
277// Find the file object
278//
279 if (!(fp = XrdPosixObject::File(fildes))) return -1;
280
281// We need to implement this
282//
283 return 0;
284}

References XrdPosixObject::File().

Here is the call graph for this function:

◆ PreRead() [2/2]

int XrdPosixExtra::PreRead ( int fildes,
XrdOucRangeList & rlist )
static

Preread a list of byte ranges in one operation

Parameters
fildes- File descriptor The file descriptor must refer to an open file.
rlist- list of the byte ranges to preread. The default maximum size is 2097136 bytes and the default maximum number of request is 1024. Be aware the the server may support a different combination and may be queried for its defaults.
Returns
0 Request accepted.
< 0 Request rejected, errno hold reason for failure.

Definition at line 286 of file XrdPosixExtra.cc.

287{
288 XrdPosixFile *fp;
289
290// Find the file object
291//
292 if (!(fp = XrdPosixObject::File(fildes))) return -1;
293
294// We need to implement this so for now we just pretend this worked
295//
296 return 0;
297}

References XrdPosixObject::File().

Here is the call 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 109 of file XrdPosixExtra.hh.

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


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