XRootD
XrdOss.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d O s s . c c */
4 /* */
5 /* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Andrew Hanushevsky for Stanford University under contract */
8 /* DE-AC02-76-SFO0515 with the Department of Energy */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 #include "XrdOss/XrdOss.hh"
33 #include "XrdSfs/XrdSfsAio.hh"
34 
35 /******************************************************************************/
36 /* C l a s s X r d O s s */
37 /******************************************************************************/
38 /******************************************************************************/
39 /* C o n n e c t */
40 /******************************************************************************/
41 
42 void XrdOss::Connect(XrdOucEnv &env) {(void)env;}
43 
44 /******************************************************************************/
45 /* D i s c */
46 /******************************************************************************/
47 
48 void XrdOss::Disc(XrdOucEnv &env) {(void)env;}
49 
50 /******************************************************************************/
51 /* E n v I n f o */
52 /******************************************************************************/
53 
55 
56 /******************************************************************************/
57 /* F e a t u r e s */
58 /******************************************************************************/
59 
60 uint64_t XrdOss::Features() {return 0;}
61 
62 /******************************************************************************/
63 /* F S c t l */
64 /******************************************************************************/
65 
66 int XrdOss::FSctl(int cmd, int alen, const char *args, char **resp)
67 {
68  (void)cmd; (void)alen; (void)args; (void)resp;
69  return -ENOTSUP;
70 }
71 
72 /******************************************************************************/
73 /* R e l o c */
74 /******************************************************************************/
75 
76 int XrdOss::Reloc(const char *tident, const char *path,
77  const char *cgName, const char *anchor)
78 {
79  (void)tident; (void)path; (void)cgName; (void)anchor;
80  return -ENOTSUP;
81 }
82 
83 /******************************************************************************/
84 /* S t a t F S */
85 /******************************************************************************/
86 
87 int XrdOss::StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP)
88 {
89  (void)path; (void)buff; (void)blen; (void)eP;
90  return -ENOTSUP;
91 }
92 
93 /******************************************************************************/
94 /* S t a t L S */
95 /******************************************************************************/
96 
97 int XrdOss::StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
98 {
99  (void)env; (void)cgrp; (void)buff; (void)blen;
100  return -ENOTSUP;
101 }
102 
103 /******************************************************************************/
104 /* S t a t P F */
105 /******************************************************************************/
106 
107 int XrdOss::StatPF(const char *path, struct stat *buff, int opts)
108 {
109  (void)path; (void)buff;
110  return -ENOTSUP;
111 }
112 
113 /******************************************************************************/
114 /* S t a t V S */
115 /******************************************************************************/
116 
117 int XrdOss::StatVS(XrdOssVSInfo *sP, const char *sname, int updt)
118 {
119  (void)sP; (void)sname; (void)updt;
120  return -ENOTSUP;
121 }
122 
123 /******************************************************************************/
124 /* S t a t X A */
125 /******************************************************************************/
126 
127 int XrdOss::StatXA(const char *path, char *buff, int &blen, XrdOucEnv *eP)
128 {
129  (void)path; (void)buff; (void)blen; (void)eP;
130  return -ENOTSUP;
131 }
132 
133 /******************************************************************************/
134 /* S t a t X P */
135 /******************************************************************************/
136 
137 int XrdOss::StatXP(const char *path, unsigned long long &attr, XrdOucEnv *eP)
138 {
139  (void)path; (void)attr; (void)eP;
140  return -ENOTSUP;
141 }
142 
143 /******************************************************************************/
144 /* C l a s s X r d O s s D F */
145 /******************************************************************************/
146 /******************************************************************************/
147 /* F c t l */
148 /******************************************************************************/
149 
150 int XrdOssDF::Fctl(int cmd, int alen, const char *args, char **resp)
151 {
152  (void)cmd; (void)alen; (void)args; (void)resp;
153  return -ENOTSUP;
154 }
155 
156 /******************************************************************************/
157 /* p g R e a d */
158 /******************************************************************************/
159 
160 ssize_t XrdOssDF::pgRead(void *buffer,
161  off_t offset,
162  size_t rdlen,
163  uint32_t *csvec,
164  uint64_t opts)
165 {
166  ssize_t bytes;
167 
168 // Read the data into the buffer
169 //
170  bytes = Read(buffer, offset, rdlen);
171 
172 // Calculate checksums if so wanted
173 //
174  if (bytes > 0 && csvec)
175  XrdOucPgrwUtils::csCalc((const char *)buffer, offset, bytes, csvec);
176 
177 // All done
178 //
179  return bytes;
180 }
181 
182 /******************************************************************************/
183 
184 int XrdOssDF::pgRead(XrdSfsAio *aioparm, uint64_t opts)
185 {
186  aioparm->Result = this->pgRead((void *)aioparm->sfsAio.aio_buf,
187  (off_t) aioparm->sfsAio.aio_offset,
188  (size_t)aioparm->sfsAio.aio_nbytes,
189  aioparm->cksVec, opts);
190  aioparm->doneRead();
191  return 0;
192 }
193 
194 /******************************************************************************/
195 /* p g W r i t e */
196 /******************************************************************************/
197 
198 ssize_t XrdOssDF::pgWrite(void *buffer,
199  off_t offset,
200  size_t wrlen,
201  uint32_t *csvec,
202  uint64_t opts)
203 {
204 
205 // If we have a checksum vector and verify is on, make sure the data
206 // in the buffer corresponds to he checksums.
207 //
208  if (csvec && (opts & Verify))
209  {XrdOucPgrwUtils::dataInfo dInfo((const char *)buffer,csvec,offset,wrlen);
210  off_t bado;
211  int badc;
212  if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
213  }
214 
215 // Now just return the result of a plain write
216 //
217  return Write(buffer, offset, wrlen);
218 }
219 
220 /******************************************************************************/
221 
222 int XrdOssDF::pgWrite(XrdSfsAio *aioparm, uint64_t opts)
223 {
224  aioparm->Result = this->pgWrite((void *)aioparm->sfsAio.aio_buf,
225  (off_t) aioparm->sfsAio.aio_offset,
226  (size_t)aioparm->sfsAio.aio_nbytes,
227  aioparm->cksVec, opts);
228  aioparm->doneWrite();
229  return 0;
230 }
231 
232 /******************************************************************************/
233 /* R e a d V */
234 /******************************************************************************/
235 
237  int n)
238 {
239  ssize_t nbytes = 0, curCount = 0;
240  for (int i=0; i<n; i++)
241  {curCount = Read((void *)readV[i].data,
242  (off_t)readV[i].offset,
243  (size_t)readV[i].size);
244  if (curCount != readV[i].size)
245  {if (curCount < 0) return curCount;
246  return -ESPIPE;
247  }
248  nbytes += curCount;
249  }
250  return nbytes;
251 }
252 
253 /******************************************************************************/
254 /* W r i t e V */
255 /******************************************************************************/
256 
258  int n)
259 {
260  ssize_t nbytes = 0, curCount = 0;
261 
262  for (int i=0; i<n; i++)
263  {curCount =Write((void *)writeV[i].data,
264  (off_t)writeV[i].offset,
265  (size_t)writeV[i].size);
266  if (curCount != writeV[i].size)
267  {if (curCount < 0) return curCount;
268  return -ESPIPE;
269  }
270  nbytes += curCount;
271  }
272  return nbytes;
273 }
#define tident
int stat(const char *path, struct stat *buf)
struct myOpts opts
off_t aio_offset
Definition: XrdSfsAio.hh:49
size_t aio_nbytes
Definition: XrdSfsAio.hh:48
void * aio_buf
Definition: XrdSfsAio.hh:47
virtual ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt)
Definition: XrdOss.cc:257
static const uint64_t Verify
all: Verify checksums
Definition: XrdOss.hh:223
virtual ssize_t Read(off_t offset, size_t size)
Definition: XrdOss.hh:281
virtual int Fctl(int cmd, int alen, const char *args, char **resp=0)
Definition: XrdOss.cc:150
virtual ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
Definition: XrdOss.cc:198
virtual ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
Definition: XrdOss.cc:160
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
Definition: XrdOss.cc:236
virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
Definition: XrdOss.hh:345
virtual int FSctl(int cmd, int alen, const char *args, char **resp=0)
Definition: XrdOss.cc:66
virtual int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen)
Definition: XrdOss.cc:97
virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
Definition: XrdOss.cc:127
virtual int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *envP=0)
Definition: XrdOss.cc:137
virtual void Connect(XrdOucEnv &env)
Definition: XrdOss.cc:42
virtual int Reloc(const char *tident, const char *path, const char *cgName, const char *anchor=0)
Definition: XrdOss.cc:76
virtual uint64_t Features()
Definition: XrdOss.cc:60
virtual int StatPF(const char *path, struct stat *buff, int opts)
Definition: XrdOss.cc:107
virtual void Disc(XrdOucEnv &env)
Definition: XrdOss.cc:48
virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0)
Definition: XrdOss.cc:117
virtual int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
Definition: XrdOss.cc:87
virtual void EnvInfo(XrdOucEnv *envP)
Definition: XrdOss.cc:54
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)
static bool csVer(dataInfo &dInfo, off_t &bado, int &badc)
uint32_t * cksVec
Definition: XrdSfsAio.hh:63
ssize_t Result
Definition: XrdSfsAio.hh:65
virtual void doneRead()=0
struct aiocb sfsAio
Definition: XrdSfsAio.hh:62
virtual void doneWrite()=0
XrdOucEnv * envP
Definition: XrdPss.cc:109