xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdXrootd
XrdXrootdAio.hh
Go to the documentation of this file.
1
#ifndef __XRDXROOTDAIO__
2
#define __XRDXROOTDAIO__
3
/******************************************************************************/
4
/* */
5
/* X r d X r o o t d A i o . h h */
6
/* */
7
/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/* */
12
/* This file is part of the XRootD software suite. */
13
/* */
14
/* XRootD is free software: you can redistribute it and/or modify it under */
15
/* the terms of the GNU Lesser General Public License as published by the */
16
/* Free Software Foundation, either version 3 of the License, or (at your */
17
/* option) any later version. */
18
/* */
19
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22
/* License for more details. */
23
/* */
24
/* You should have received a copy of the GNU Lesser General Public License */
25
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27
/* */
28
/* The copyright holder's institutional names and contributor's names may not */
29
/* be used to endorse or promote products derived from this software without */
30
/* specific prior written permission of the institution or contributor. */
31
/******************************************************************************/
32
33
#include "
XProtocol/XPtypes.hh
"
34
#include "
XrdSys/XrdSysPthread.hh
"
35
#include "
XrdSfs/XrdSfsAio.hh
"
36
#include "
Xrd/XrdScheduler.hh
"
37
#include "
XrdXrootd/XrdXrootdResponse.hh
"
38
39
/******************************************************************************/
40
/* X r d X r o o t d A i o */
41
/******************************************************************************/
42
43
// The XrdXrootdAio object represents a single aio read or write operation. One
44
// or more of these are allocated to the XrdXrootdAioReq and passed as upcast
45
// arguments to the sfs file object to effect asynchronous I/O.
46
47
class
XrdBuffer
;
48
class
XrdBuffManager
;
49
class
XrdSysError
;
50
class
XrdXrootdAioReq
;
51
class
XrdXrootdStats
;
52
53
class
XrdXrootdAio
:
public
XrdSfsAio
54
{
55
friend
class
XrdXrootdAioReq
;
56
public
:
57
XrdBuffer
*
buffp
;
// -> Buffer object
58
59
virtual
void
doneRead
();
60
61
virtual
void
doneWrite
();
62
63
virtual
void
Recycle
();
64
65
66
XrdXrootdAio
() {
Next
=0;
aioReq
=0;
buffp
=0;}
67
~XrdXrootdAio
() {};
68
69
private
:
70
71
static
XrdXrootdAio
*
Alloc
(
XrdXrootdAioReq
*arp,
int
bsize=0);
72
static
XrdXrootdAio
*
addBlock
();
73
74
static
const
char
*
TraceID
;
75
static
XrdBuffManager
*
BPool
;
// -> Buffer Manager
76
static
XrdScheduler
*
Sched
;
// -> System Scheduler
77
static
XrdXrootdStats
*
SI
;
// -> System Statistics
78
static
XrdSysMutex
fqMutex
;
// Locks static data
79
static
XrdXrootdAio
*
fqFirst
;
// -> Object in free queue
80
static
int
maxAio
;
// Maximum Aio objects we can yet have
81
82
XrdXrootdAio
*
Next
;
// Chain pointer
83
XrdXrootdAioReq
*
aioReq
;
// -> Associated request object
84
};
85
86
/******************************************************************************/
87
/* X r d X r o o t d A i o R e q */
88
/******************************************************************************/
89
90
// The XrdXrootdAioReq object represents a complete aio request. It handles
91
// the appropriate translation of the synchrnous request to an async one,
92
// provides the redrive logic, and handles ending status.
93
//
94
class
XrdLink
;
95
class
XrdXrootdFile
;
96
class
XrdXrootdProtocol
;
97
98
class
XrdXrootdAioReq
:
public
XrdJob
99
{
100
friend
class
XrdXrootdAio
;
101
public
:
102
103
static
XrdXrootdAioReq
*
Alloc
(
XrdXrootdProtocol
*p,
char
iot,
int
numaio=0);
104
105
void
DoIt
() {
if
(
aioType
==
'r'
)
endRead
();
106
else
endWrite
();
107
}
108
109
XrdXrootdAio
*
getAio
();
110
111
inline
XrdXrootdAio
*
Pop
() {
XrdXrootdAio
*aiop =
aioDone
;
112
aioDone
= aiop->
Next
;
return
aiop;
113
}
114
115
inline
void
Push
(
XrdXrootdAio
*newp)
116
{newp->
Next
=
aioDone
;
aioDone
= newp;}
117
118
static
void
Init
(
int
iosize,
int
maxaiopr,
int
maxaio=-80);
119
120
int
Read
();
121
122
void
Recycle
(
int
deref=1,
XrdXrootdAio
*aiop=0);
123
124
int
Write
(
XrdXrootdAio
*aiop);
125
126
XrdXrootdAioReq
() :
XrdJob
(
"aio request"
) {}
127
~XrdXrootdAioReq
() {}
// Never called
128
129
private
:
130
131
void
Clear
(
XrdLink
*lnkp);
132
133
static
XrdXrootdAioReq
*
addBlock
();
134
void
endRead
();
135
void
endWrite
();
136
inline
void
Lock
() {
aioMutex
.
Lock
();
isLocked
= 1;}
137
void
Scuttle
(
const
char
*opname);
138
void
sendError
(
char
*
tident
);
139
inline
void
UnLock
() {
isLocked
= 0;
aioMutex
.
UnLock
();}
140
141
static
const
char
*
TraceID
;
142
static
XrdSysError
*
eDest
;
// -> Error Object
143
static
XrdSysMutex
rqMutex
;
// Locks static data
144
static
XrdXrootdAioReq
*
rqFirst
;
// -> Object in free queue
145
static
int
QuantumMin
;
// aio segment size (Quantum/2)
146
static
int
Quantum
;
// aio segment size
147
static
int
QuantumMax
;
// aio segment size (Quantum*2)
148
static
int
maxAioPR
;
// aio objects per request (max)
149
static
int
maxAioPR2
;
// aio objects per request (max*2)
150
151
XrdSysMutex
aioMutex
;
// Locks private data
152
XrdXrootdAioReq
*
Next
;
// -> Chain pointer
153
154
off_t
myOffset
;
// Next offset (used for read's only)
155
int
myIOLen
;
// Size remaining (read and write end)
156
unsigned
int
Instance
;
// Network Link Instance
157
XrdLink
*
Link
;
// -> Network link
158
XrdXrootdFile
*
myFile
;
// -> Associated file
159
160
XrdXrootdAio
*
aioDone
;
// Next aiocb that completed
161
XrdXrootdAio
*
aioFree
;
// Next aiocb that we can use
162
int
numActive
;
// Number of aio requests outstanding
163
int
aioTotal
;
// Actual number of disk bytes transferred
164
int
aioError
;
// First errno encounetered
165
char
aioType
;
// 'r' or 'w' or 's'
166
char
respDone
;
// 1 -> Response has been sent
167
char
isLocked
;
// 1 -> Object lock being held
168
char
reDrive
;
// 1 -> Link redrive is needed
169
170
XrdXrootdResponse
Response
;
// Copy of the original response object
171
};
172
#endif
Generated by
1.8.3.1