XRootD
Loading...
Searching...
No Matches
XrdSfsInterface.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d S f s I n t e r f a c e . h h */
4/* */
5/* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* Produced by Andrew Hanushevsky for Stanford University under contract */
7/* DE-AC02-76-SFO0515 with the Department of Energy */
8/* */
9/* This file is part of the XRootD software suite. */
10/* */
11/* XRootD is free software: you can redistribute it and/or modify it under */
12/* the terms of the GNU Lesser General Public License as published by the */
13/* Free Software Foundation, either version 3 of the License, or (at your */
14/* option) any later version. */
15/* */
16/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19/* License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24/* */
25/* The copyright holder's institutional names and contributor's names may not */
26/* be used to endorse or promote products derived from this software without */
27/* specific prior written permission of the institution or contributor. */
28/******************************************************************************/
29
30#include <cassert>
31#include <cstdio>
32#include <arpa/inet.h>
33
36#include "XrdSfs/XrdSfsAio.hh"
37#include "XrdSfs/XrdSfsFlags.hh"
39
40/******************************************************************************/
41/* X r d S f s D i r e c t o r y M e t h o d D e f a u l t s */
42/******************************************************************************/
43/******************************************************************************/
44/* a u t o s t a t */
45/******************************************************************************/
46
48{
49 (void)buf;
50 error.setErrInfo(ENOTSUP, "Not supported.");
51 return SFS_ERROR;
52}
53
54/******************************************************************************/
55/* X r d S f s F i l e M e t h o d D e f a u l t s */
56/******************************************************************************/
57/******************************************************************************/
58/* c h e c k p o i n t */
59/******************************************************************************/
60
61int XrdSfsFile::checkpoint(cpAct act, struct iov *range, int n)
62{
63// Provide reasonable answers
64//
65 switch(act)
66 {case cpCreate: error.setErrInfo(EDQUOT,"Checkpoint quota exceeded.");
67 break;
68 case cpDelete:
69 case cpRestore: error.setErrInfo(ENOENT,"Checkpoint does not exist.");
70 break;
71 default: error.setErrInfo(EINVAL,"Invalid checkpoint request.");
72 break;
73 }
74 return SFS_ERROR;
75}
76
77/******************************************************************************/
78/* C l o n e */
79/******************************************************************************/
80
82{
83 (void)srcFile;
84 error.setErrInfo(ENOTSUP, "Not supported.");
85 return SFS_ERROR;
86}
87
88int XrdSfsFile::Clone(const std::vector<XrdOucCloneSeg> &cVec)
89{
90 (void)cVec;
91 error.setErrInfo(ENOTSUP, "Not supported.");
92 return SFS_ERROR;
93}
94
95/******************************************************************************/
96/* f c t l */
97/******************************************************************************/
98
99int XrdSfsFile::fctl(const int cmd,
100 int alen,
101 const char *args,
102 const XrdSecEntity *client)
103{
104 (void)cmd; (void)alen; (void)args; (void)client;
105 return SFS_OK;
106}
107
108/******************************************************************************/
109/* p g R e a d */
110/******************************************************************************/
111
113 char *buffer,
114 XrdSfsXferSize rdlen,
115 uint32_t *csvec,
116 uint64_t opts)
117{
118 XrdSfsXferSize bytes;
119
120// Read the data into the buffer
121//
122 if ((bytes = read(offset, buffer, rdlen)) <= 0) return bytes;
123
124// Generate the crc's.
125//
126 XrdOucPgrwUtils::csCalc(buffer, offset, bytes, csvec);
127
128// All done
129//
130 return bytes;
131}
132
133/******************************************************************************/
134
136{
137 aioparm->Result = this->pgRead((XrdSfsFileOffset)aioparm->sfsAio.aio_offset,
138 (char *)aioparm->sfsAio.aio_buf,
140 aioparm->cksVec, opts);
141 aioparm->doneRead();
142 return SFS_OK;
143}
144
145/******************************************************************************/
146/* p g W r i t e */
147/******************************************************************************/
148
150 char *buffer,
151 XrdSfsXferSize wrlen,
152 uint32_t *csvec,
153 uint64_t opts)
154{
155
156// If we have a checksum vector and verify is on, do verification.
157//
158 if (opts & Verify)
159 {XrdOucPgrwUtils::dataInfo dInfo(buffer, csvec, offset, wrlen);
160 off_t badoff;
161 int badlen;
162
163 if (!XrdOucPgrwUtils::csVer(dInfo, badoff, badlen))
164 {char eMsg[512];
165 snprintf(eMsg, sizeof(eMsg), "Checksum error at offset %lld.", (long long) badoff);
166 error.setErrInfo(EDOM, eMsg);
167 return SFS_ERROR;
168 }
169 }
170
171// Now just return the result of a plain write
172//
173 return write(offset, buffer, wrlen);
174}
175
176/******************************************************************************/
177
179{
180 aioparm->Result = this->pgWrite((XrdSfsFileOffset)aioparm->sfsAio.aio_offset,
181 (char *)aioparm->sfsAio.aio_buf,
183 aioparm->cksVec, opts);
184 aioparm->doneWrite();
185 return SFS_OK;
186}
187
188/******************************************************************************/
189/* r e a d */
190/******************************************************************************/
191
193{
194 for (auto it = rlist.begin(); it != rlist.end(); it++)
195 if (read(it->offset, it->size) == SFS_ERROR) return SFS_ERROR;
196 return 1;
197}
198
199/******************************************************************************/
200/* r e a d v */
201/******************************************************************************/
202
204 int rdvCnt)
205{
206 XrdSfsXferSize rdsz, totbytes = 0;
207
208 for (int i = 0; i < rdvCnt; i++)
209 {rdsz = read(readV[i].offset,
210 readV[i].data, readV[i].size);
211 if (rdsz != readV[i].size)
212 {if (rdsz < 0) return rdsz;
213 error.setErrInfo(ESPIPE,"read past eof");
214 return SFS_ERROR;
215 }
216 totbytes += rdsz;
217 }
218 return totbytes;
219}
220
221/******************************************************************************/
222/* S e n d D a t a */
223/******************************************************************************/
224
226 XrdSfsFileOffset offset,
227 XrdSfsXferSize size)
228{
229 (void)sfDio; (void)offset; (void)size;
230 return SFS_OK;
231}
232
233/******************************************************************************/
234/* w r i t e v */
235/******************************************************************************/
236
238 int wdvCnt)
239{
240 XrdSfsXferSize wrsz, totbytes = 0;
241
242 for (int i = 0; i < wdvCnt; i++)
243 {wrsz = write(writeV[i].offset,
244 writeV[i].data, writeV[i].size);
245 if (wrsz != writeV[i].size)
246 {if (wrsz < 0) return wrsz;
247 error.setErrInfo(ESPIPE,"write past eof");
248 return SFS_ERROR;
249 }
250 totbytes += wrsz;
251 }
252 return totbytes;
253}
254
255/******************************************************************************/
256/* X r d S f s F i l e S y s t e m M e t h o d D e f a u l t s */
257/******************************************************************************/
258/******************************************************************************/
259/* C o n s t r u c t o r */
260/******************************************************************************/
261
267
268/******************************************************************************/
269/* c h k s u m */
270/******************************************************************************/
271
273 const char *csName,
274 const char *path,
275 XrdOucErrInfo &eInfo,
276 const XrdSecEntity *client,
277 const char *opaque)
278{
279 (void)Func; (void)csName; (void)path; (void)eInfo; (void)client;
280 (void)opaque;
281
282 eInfo.setErrInfo(ENOTSUP, "Not supported.");
283 return SFS_ERROR;
284}
285
286/******************************************************************************/
287/* F A t t r */
288/******************************************************************************/
289
291 XrdOucErrInfo &eInfo,
292 const XrdSecEntity *client)
293{
294 (void)faReq; (void)client;
295
296 eInfo.setErrInfo(ENOTSUP, "Not supported.");
297 return SFS_ERROR;
298}
299
300/******************************************************************************/
301/* F S c t l */
302/******************************************************************************/
303
304int XrdSfsFileSystem::FSctl(const int cmd,
305 XrdSfsFSctl &args,
306 XrdOucErrInfo &eInfo,
307 const XrdSecEntity *client)
308{
309 (void)cmd; (void)args; (void)eInfo; (void)client;
310
311 return SFS_OK;
312}
313
314/******************************************************************************/
315/* g p F i l e */
316/******************************************************************************/
317
319 XrdSfsGPFile &gpReq,
320 XrdOucErrInfo &eInfo,
321 const XrdSecEntity *client)
322{
323 (void)gpAct, (void)gpReq; (void)client;
324
325 eInfo.setErrInfo(ENOTSUP, "Not supported.");
326 return SFS_ERROR;
327}
std::vector< XrdOucRange > XrdOucRangeList
#define write(a, b, c)
Definition XrdPosix.hh:115
#define stat(a, b)
Definition XrdPosix.hh:101
#define read(a, b, c)
Definition XrdPosix.hh:82
#define eMsg(x)
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
#define SFS_ERROR
#define SFS_OK
long long XrdSfsFileOffset
int XrdSfsXferSize
int setErrInfo(int code, const char *emsg)
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
virtual int autoStat(struct stat *buf)
XrdOucErrInfo & error
XrdSfsFileSystem()
Constructor and Destructor.
virtual int FSctl(const int cmd, XrdSfsFSctl &args, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)
virtual int chksum(csFunc Func, const char *csName, const char *path, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0, const char *opaque=0)
virtual int getChkPSize()
uint64_t FeatureSet
Adjust features at initialization.
virtual int gpFile(gpfFunc &gpAct, XrdSfsGPFile &gpReq, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)
virtual int FAttr(XrdSfsFACtl *faReq, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)
static const uint64_t Verify
Options for pgRead() and pgWrite() as noted below.
virtual XrdSfsXferSize writev(XrdOucIOVec *writeV, int wdvCnt)
XrdOucErrInfo & error
virtual int SendData(XrdSfsDio *sfDio, XrdSfsFileOffset offset, XrdSfsXferSize size)
virtual XrdSfsXferSize read(XrdSfsFileOffset offset, XrdSfsXferSize size)=0
virtual XrdSfsXferSize readv(XrdOucIOVec *readV, int rdvCnt)
virtual int Clone(XrdSfsFile &srcFile)
virtual int checkpoint(cpAct act, struct iov *range=0, int n=0)
@ cpDelete
Delete an existing checkpoint.
@ cpRestore
Restore an active checkpoint and delete it.
@ cpCreate
Create a checkpoint, one must not be active.
XrdSfsFile(const char *user=0, int MonID=0)
virtual int fctl(const int cmd, const char *args, XrdOucErrInfo &eInfo)=0
virtual XrdSfsXferSize pgRead(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize rdlen, uint32_t *csvec, uint64_t opts=0)
virtual XrdSfsXferSize pgWrite(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize wrlen, uint32_t *csvec, uint64_t opts=0)
static const uint64_t hasPGRW
Feature: pgRead and pgWrite.
static const uint64_t hasCHKP
Feature: Checkpointing.
< SFS_FSCTL_PLUGIN/PLUGIO/PLUGXC/PLUGFS parms