XRootD
Loading...
Searching...
No Matches
XrdPssAio.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d P s s A i o . c c */
4/* */
5/* (c) 2007 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 <cstdio>
32#include <unistd.h>
33
37#include "XrdPss/XrdPss.hh"
38#include "XrdPss/XrdPssAioCB.hh"
39#include "XrdSfs/XrdSfsAio.hh"
40
41// All AIO interfaces are defined here.
42
43/******************************************************************************/
44/* F s y n c */
45/******************************************************************************/
46
47/*
48 Function: Async fsync() a file
49
50 Input: aiop - A aio request object
51*/
52
54{
55
56// Execute this request in an asynchronous fashion
57//
59 return 0;
60}
61
62/******************************************************************************/
63/* p g R e a d */
64/******************************************************************************/
65
66/*
67 Function: Async read bytes from the associated file
68
69 Input: aiop - An aio request object
70
71 Output: <0 -> Operation failed, value is negative errno value.
72 =0 -> Operation queued
73 >0 -> Operation not queued, system resources unavailable or
74 asynchronous I/O is not supported.
75*/
76
77int XrdPssFile::pgRead(XrdSfsAio* aiop, uint64_t opts)
78{
79 XrdPssAioCB *aioCB = XrdPssAioCB::Alloc(aiop, false, true);
80 uint64_t psxOpts = (aiop->cksVec ? XrdPosixExtra::forceCS : 0);
81
82// Execute this request in an asynchronous fashion
83//
85 (off_t)aiop->sfsAio.aio_offset,
86 (size_t)aiop->sfsAio.aio_nbytes,
87 aioCB->csVec, psxOpts, aioCB);
88 return 0;
89}
90
91/******************************************************************************/
92/* p g W r i t e */
93/******************************************************************************/
94
95/*
96 Function: Async write bytes from into the associated file
97
98 Input: aiop - An aio request object.
99
100 Output: <0 -> Operation failed, value is negative errno value.
101 =0 -> Operation queued
102 >0 -> Operation not queued, system resources unavailable or
103 asynchronous I/O is not supported.
104*/
105
107{
108
109// Check if caller wants to verify the checksums before writing
110//
111 if (aiop->cksVec && (opts & XrdOssDF::Verify))
112 {XrdOucPgrwUtils::dataInfo dInfo((const char *)(aiop->sfsAio.aio_buf),
113 aiop->cksVec, aiop->sfsAio.aio_offset,
114 aiop->sfsAio.aio_nbytes);
115 off_t bado;
116 int badc;
117 if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
118 }
119
120// Get a callback object as no errors can error here
121//
122 XrdPssAioCB *aioCB = XrdPssAioCB::Alloc(aiop, true, true);
123
124// Check if caller want checksum generated and possibly returned
125//
126 if ((opts & XrdOssDF::doCalc) || aiop->cksVec == 0)
127 {XrdOucPgrwUtils::csCalc((const char *)(aiop->sfsAio.aio_buf),
128 (off_t)(aiop->sfsAio.aio_offset),
129 (size_t)(aiop->sfsAio.aio_nbytes),
130 aioCB->csVec);
131 if (aiop->cksVec) memcpy(aiop->cksVec, aioCB->csVec.data(),
132 aioCB->csVec.size()*sizeof(uint32_t));
133 } else {
135 aiop->sfsAio.aio_nbytes);
136 aioCB->csVec.resize(n);
137 aioCB->csVec.assign(n, 0);
138 memcpy(aioCB->csVec.data(), aiop->cksVec, n*sizeof(uint32_t));
139 }
140
141// Issue the pgWrite
142//
144 (off_t)aiop->sfsAio.aio_offset,
145 (size_t)aiop->sfsAio.aio_nbytes,
146 aioCB->csVec, 0, aioCB);
147 return 0;
148}
149
150/******************************************************************************/
151/* R e a d */
152/******************************************************************************/
153
154/*
155 Function: Async read `blen' bytes from the associated file, placing in 'buff'
156
157 Input: aiop - An aio request object
158
159 Output: <0 -> Operation failed, value is negative errno value.
160 =0 -> Operation queued
161 >0 -> Operation not queued, system resources unavailable or
162 asynchronous I/O is not supported.
163*/
164
166{
167
168// Execute this request in an asynchronous fashion
169//
170 XrdPosixXrootd::Pread(fd, (void *)aiop->sfsAio.aio_buf,
171 (size_t)aiop->sfsAio.aio_nbytes,
172 (off_t)aiop->sfsAio.aio_offset,
173 XrdPssAioCB::Alloc(aiop, false));
174 return 0;
175}
176
177/******************************************************************************/
178/* W r i t e */
179/******************************************************************************/
180
181/*
182 Function: Async write `blen' bytes from 'buff' into the associated file
183
184 Input: aiop - An aio request object.
185
186 Output: <0 -> Operation failed, value is negative errno value.
187 =0 -> Operation queued
188 >0 -> Operation not queued, system resources unavailable or
189 asynchronous I/O is not supported.
190*/
191
193{
194
195// Execute this request in an asynchronous fashion
196//
197 XrdPosixXrootd::Pwrite(fd, (const void *)aiop->sfsAio.aio_buf,
198 (size_t)aiop->sfsAio.aio_nbytes,
199 (off_t)aiop->sfsAio.aio_offset,
200 XrdPssAioCB::Alloc(aiop, true));
201 return 0;
202}
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
static const uint64_t doCalc
pgw: Calculate checksums
Definition XrdOss.hh:225
int fd
Definition XrdOss.hh:455
static const uint64_t Verify
all: Verify checksums
Definition XrdOss.hh:223
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)
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
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 const uint64_t forceCS
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 Pread(int fildes, void *buf, size_t nbyte, off_t offset)
Pread() conforms to POSIX.1-2001 pread()
static int Fsync(int fildes)
Fsync() conforms to POSIX.1-2001 fsync()
static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
Pwrite() conforms to POSIX.1-2001 pwrite()
std::vector< uint32_t > csVec
static XrdPssAioCB * Alloc(XrdSfsAio *aiop, bool isWr, bool pgrw=false)
int Fsync()
Definition XrdPss.cc:1261
ssize_t Read(off_t, size_t)
Definition XrdPss.cc:1057
ssize_t Write(const void *, off_t, size_t)
Definition XrdPss.cc:1153
ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
Definition XrdPss.cc:948
ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
Definition XrdPss.cc:1001
uint32_t * cksVec
Definition XrdSfsAio.hh:63
struct aiocb sfsAio
Definition XrdSfsAio.hh:62