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
35#include "XrdSfs/XrdSfsAio.hh"
36#include "XrdSfs/XrdSfsFlags.hh"
38
39/******************************************************************************/
40/* 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 */
41/******************************************************************************/
42/******************************************************************************/
43/* a u t o s t a t */
44/******************************************************************************/
45
47{
48 (void)buf;
49 error.setErrInfo(ENOTSUP, "Not supported.");
50 return SFS_ERROR;
51}
52
53/******************************************************************************/
54/* X r d S f s F i l e M e t h o d D e f a u l t s */
55/******************************************************************************/
56/******************************************************************************/
57/* c h e c k p o i n t */
58/******************************************************************************/
59
60int XrdSfsFile::checkpoint(cpAct act, struct iov *range, int n)
61{
62// Provide reasonable answers
63//
64 switch(act)
65 {case cpCreate: error.setErrInfo(EDQUOT,"Checkpoint quota exceeded.");
66 break;
67 case cpDelete:
68 case cpRestore: error.setErrInfo(ENOENT,"Checkpoint does not exist.");
69 break;
70 default: error.setErrInfo(EINVAL,"Invalid checkpoint request.");
71 break;
72 }
73 return SFS_ERROR;
74}
75
76/******************************************************************************/
77/* f c t l */
78/******************************************************************************/
79
80int XrdSfsFile::fctl(const int cmd,
81 int alen,
82 const char *args,
83 const XrdSecEntity *client)
84{
85 (void)cmd; (void)alen; (void)args; (void)client;
86 return SFS_OK;
87}
88
89/******************************************************************************/
90/* p g R e a d */
91/******************************************************************************/
92
94 char *buffer,
95 XrdSfsXferSize rdlen,
96 uint32_t *csvec,
97 uint64_t opts)
98{
99 XrdSfsXferSize bytes;
100
101// Read the data into the buffer
102//
103 if ((bytes = read(offset, buffer, rdlen)) <= 0) return bytes;
104
105// Generate the crc's.
106//
107 XrdOucPgrwUtils::csCalc(buffer, offset, bytes, csvec);
108
109// All done
110//
111 return bytes;
112}
113
114/******************************************************************************/
115
117{
118 aioparm->Result = this->pgRead((XrdSfsFileOffset)aioparm->sfsAio.aio_offset,
119 (char *)aioparm->sfsAio.aio_buf,
121 aioparm->cksVec, opts);
122 aioparm->doneRead();
123 return SFS_OK;
124}
125
126/******************************************************************************/
127/* p g W r i t e */
128/******************************************************************************/
129
131 char *buffer,
132 XrdSfsXferSize wrlen,
133 uint32_t *csvec,
134 uint64_t opts)
135{
136
137// If we have a checksum vector and verify is on, do verification.
138//
139 if (opts & Verify)
140 {XrdOucPgrwUtils::dataInfo dInfo(buffer, csvec, offset, wrlen);
141 off_t badoff;
142 int badlen;
143
144 if (!XrdOucPgrwUtils::csVer(dInfo, badoff, badlen))
145 {char eMsg[512];
146 snprintf(eMsg, sizeof(eMsg), "Checksum error at offset %lld.", (long long) badoff);
147 error.setErrInfo(EDOM, eMsg);
148 return SFS_ERROR;
149 }
150 }
151
152// Now just return the result of a plain write
153//
154 return write(offset, buffer, wrlen);
155}
156
157/******************************************************************************/
158
160{
161 aioparm->Result = this->pgWrite((XrdSfsFileOffset)aioparm->sfsAio.aio_offset,
162 (char *)aioparm->sfsAio.aio_buf,
164 aioparm->cksVec, opts);
165 aioparm->doneWrite();
166 return SFS_OK;
167}
168
169/******************************************************************************/
170/* r e a d v */
171/******************************************************************************/
172
174 int rdvCnt)
175{
176 XrdSfsXferSize rdsz, totbytes = 0;
177
178 for (int i = 0; i < rdvCnt; i++)
179 {rdsz = read(readV[i].offset,
180 readV[i].data, readV[i].size);
181 if (rdsz != readV[i].size)
182 {if (rdsz < 0) return rdsz;
183 error.setErrInfo(ESPIPE,"read past eof");
184 return SFS_ERROR;
185 }
186 totbytes += rdsz;
187 }
188 return totbytes;
189}
190
191/******************************************************************************/
192/* S e n d D a t a */
193/******************************************************************************/
194
196 XrdSfsFileOffset offset,
197 XrdSfsXferSize size)
198{
199 (void)sfDio; (void)offset; (void)size;
200 return SFS_OK;
201}
202
203/******************************************************************************/
204/* w r i t e v */
205/******************************************************************************/
206
208 int wdvCnt)
209{
210 XrdSfsXferSize wrsz, totbytes = 0;
211
212 for (int i = 0; i < wdvCnt; i++)
213 {wrsz = write(writeV[i].offset,
214 writeV[i].data, writeV[i].size);
215 if (wrsz != writeV[i].size)
216 {if (wrsz < 0) return wrsz;
217 error.setErrInfo(ESPIPE,"write past eof");
218 return SFS_ERROR;
219 }
220 totbytes += wrsz;
221 }
222 return totbytes;
223}
224
225/******************************************************************************/
226/* 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 */
227/******************************************************************************/
228/******************************************************************************/
229/* C o n s t r u c t o r */
230/******************************************************************************/
231
237
238/******************************************************************************/
239/* c h k s u m */
240/******************************************************************************/
241
243 const char *csName,
244 const char *path,
245 XrdOucErrInfo &eInfo,
246 const XrdSecEntity *client,
247 const char *opaque)
248{
249 (void)Func; (void)csName; (void)path; (void)eInfo; (void)client;
250 (void)opaque;
251
252 eInfo.setErrInfo(ENOTSUP, "Not supported.");
253 return SFS_ERROR;
254}
255
256/******************************************************************************/
257/* F A t t r */
258/******************************************************************************/
259
261 XrdOucErrInfo &eInfo,
262 const XrdSecEntity *client)
263{
264 (void)faReq; (void)client;
265
266 eInfo.setErrInfo(ENOTSUP, "Not supported.");
267 return SFS_ERROR;
268}
269
270/******************************************************************************/
271/* F S c t l */
272/******************************************************************************/
273
274int XrdSfsFileSystem::FSctl(const int cmd,
275 XrdSfsFSctl &args,
276 XrdOucErrInfo &eInfo,
277 const XrdSecEntity *client)
278{
279 (void)cmd; (void)args; (void)eInfo; (void)client;
280
281 return SFS_OK;
282}
283
284/******************************************************************************/
285/* g p F i l e */
286/******************************************************************************/
287
289 XrdSfsGPFile &gpReq,
290 XrdOucErrInfo &eInfo,
291 const XrdSecEntity *client)
292{
293 (void)gpAct, (void)gpReq; (void)client;
294
295 eInfo.setErrInfo(ENOTSUP, "Not supported.");
296 return SFS_ERROR;
297}
#define write(a, b, c)
Definition XrdPosix.hh:110
#define stat(a, b)
Definition XrdPosix.hh:96
#define read(a, b, c)
Definition XrdPosix.hh:77
#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
< SFS_FSCTL_PLUGIN/PLUGIO/PLUGXC parms
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 readv(XrdOucIOVec *readV, int rdvCnt)
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.
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.