XRootD
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  fp->UnLock();
88  return (ssize_t)bytes;
89  }
90 
91 // Handle the read in the async case
92 //
93  cbp->theFile = fp;
94  fp->Ref(); fp->UnLock();
95 
96 // Issue the read
97 //
98  fp->XCio->pgRead(*cbp, (char *)buffer, offs, (int)iosz, csvec, fOpts);
99  return 0;
100 }
struct myOpts opts
static const uint64_t forceCS
Definition: XrdOucCache.hh:188
virtual int pgRead(char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
Definition: XrdOucCache.cc:39
virtual void Complete(ssize_t Result)=0
static const uint64_t forceCS
XrdOucCacheIO * XCio
Definition: XrdPosixFile.hh:65
static XrdPosixFile * File(int fildes, bool glk=false)

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

Referenced by 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 106 of file XrdPosixExtra.cc.

111 {
112  XrdPosixFile *fp;
113  long long offs;
114  int iosz, bytes;
115 
116 // Find the file object
117 //
118  if (!(fp = XrdPosixObject::File(fildes)))
119  {if (!cbp) return -1;
120  cbp->Complete(-1);
121  return 0;
122  }
123 
124 // Make sure the size is not too large
125 //
126  if (wrlen > (size_t)0x7fffffff)
127  {fp->UnLock();
128  errno = EOVERFLOW;
129  if (!cbp) return -1;
130  cbp->Complete(-1);
131  return 0;
132  }
133 
134 // Check if we need to generate checksums or verify that we have the right num.
135 //
136  if (csvec.size() == 0)
137  XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, csvec);
138  else if (XrdOucPgrwUtils::csNum(offset, wrlen) != (int)csvec.size())
139  {fp->UnLock();
140  errno = EINVAL;
141  if (!cbp) return -1;
142  cbp->Complete(-1);
143  return 0;
144  }
145 
146 // Get the parameters
147 //
148  iosz = static_cast<int>(wrlen);
149  offs = static_cast<long long>(offset);
150 
151 // Sync: Issue the write
152 //
153  if (!cbp)
154  {bytes = fp->XCio->pgWrite((char *)buffer, offs, (int)iosz, csvec);
155  fp->UpdtSize(offs + iosz);
156  fp->UnLock();
157  return (ssize_t)bytes;
158  }
159 
160 // Async: Prepare for writing
161 //
162  cbp->theFile = fp;
163  fp->Ref(); fp->UnLock();
164 
165 // Issue the write
166 //
167  fp->XCio->pgWrite(*cbp, (char *)buffer, offs, (int)iosz, csvec);
168  return 0;
169 }
virtual int pgWrite(char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0)
Definition: XrdOucCache.cc:68
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::File(), XrdOucCacheIO::pgWrite(), XrdPosixObject::Ref(), XrdPosixObject::UnLock(), XrdPosixFile::UpdtSize(), and XrdPosixFile::XCio.

Referenced by 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(), and XrdPssFile::pgRead().


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