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-AC03-76-SFO0515 with the Department of Energy */
11
/******************************************************************************/
12
13
// $Id$
14
15
#include "
XProtocol/XPtypes.hh
"
16
#include "
XrdSys/XrdSysPthread.hh
"
17
#include "
XrdSfs/XrdSfsAio.hh
"
18
#include "
Xrd/XrdScheduler.hh
"
19
#include "
XrdXrootd/XrdXrootdResponse.hh
"
20
21
/******************************************************************************/
22
/* X r d X r o o t d A i o */
23
/******************************************************************************/
24
25
// The XrdXrootdAio object represents a single aio read or write operation. One
26
// or more of these are allocated to the XrdXrootdAioReq and passed as upcast
27
// arguments to the sfs file object to effect asynchronous I/O.
28
29
class
XrdBuffer
;
30
class
XrdBuffManager
;
31
class
XrdSysError
;
32
class
XrdXrootdAioReq
;
33
class
XrdXrootdStats
;
34
35
class
XrdXrootdAio
:
public
XrdSfsAio
36
{
37
friend
class
XrdXrootdAioReq
;
38
public
:
39
XrdBuffer
*
buffp
;
// -> Buffer object
40
41
virtual
void
doneRead
();
42
43
virtual
void
doneWrite
();
44
45
virtual
void
Recycle
();
46
47
48
XrdXrootdAio
() {
Next
=0;
aioReq
=0;
buffp
=0;}
49
~XrdXrootdAio
() {};
50
51
private
:
52
53
static
XrdXrootdAio
*
Alloc
(
XrdXrootdAioReq
*arp,
int
bsize=0);
54
static
XrdXrootdAio
*
addBlock
();
55
56
static
const
char
*
TraceID
;
57
static
XrdBuffManager
*
BPool
;
// -> Buffer Manager
58
static
XrdScheduler
*
Sched
;
// -> System Scheduler
59
static
XrdXrootdStats
*
SI
;
// -> System Statistics
60
static
XrdSysMutex
fqMutex
;
// Locks static data
61
static
XrdXrootdAio
*
fqFirst
;
// -> Object in free queue
62
static
int
maxAio
;
// Maximum Aio objects we can yet have
63
64
XrdXrootdAio
*
Next
;
// Chain pointer
65
XrdXrootdAioReq
*
aioReq
;
// -> Associated request object
66
};
67
68
/******************************************************************************/
69
/* X r d X r o o t d A i o R e q */
70
/******************************************************************************/
71
72
// The XrdXrootdAioReq object represents a complete aio request. It handles
73
// the appropriate translation of the synchrnous request to an async one,
74
// provides the redrive logic, and handles ending status.
75
//
76
class
XrdLink
;
77
class
XrdXrootdFile
;
78
class
XrdXrootdProtocol
;
79
80
class
XrdXrootdAioReq
:
public
XrdJob
81
{
82
friend
class
XrdXrootdAio
;
83
public
:
84
85
static
XrdXrootdAioReq
*
Alloc
(
XrdXrootdProtocol
*p,
char
iot,
int
numaio=0);
86
87
void
DoIt
() {
if
(
aioType
==
'r'
)
endRead
();
88
else
endWrite
();
89
}
90
91
XrdXrootdAio
*
getAio
();
92
93
inline
XrdXrootdAio
*
Pop
() {
XrdXrootdAio
*aiop =
aioDone
;
94
aioDone
= aiop->
Next
;
return
aiop;
95
}
96
97
inline
void
Push
(
XrdXrootdAio
*newp)
98
{newp->
Next
=
aioDone
;
aioDone
= newp;}
99
100
static
void
Init
(
int
iosize,
int
maxaiopr,
int
maxaio=-80);
101
102
int
Read
();
103
104
void
Recycle
(
int
deref=1,
XrdXrootdAio
*aiop=0);
105
106
int
Write
(
XrdXrootdAio
*aiop);
107
108
XrdXrootdAioReq
() :
XrdJob
(
"aio request"
) {}
109
~XrdXrootdAioReq
() {}
// Never called
110
111
private
:
112
113
void
Clear
(
XrdLink
*lnkp);
114
115
static
XrdXrootdAioReq
*
addBlock
();
116
void
endRead
();
117
void
endWrite
();
118
inline
void
Lock
() {
aioMutex
.
Lock
();
isLocked
= 1;}
119
void
Scuttle
(
const
char
*opname);
120
void
sendError
(
char
*
tident
);
121
inline
void
UnLock
() {
isLocked
= 0;
aioMutex
.
UnLock
();}
122
123
static
const
char
*
TraceID
;
124
static
XrdSysError
*
eDest
;
// -> Error Object
125
static
XrdSysMutex
rqMutex
;
// Locks static data
126
static
XrdXrootdAioReq
*
rqFirst
;
// -> Object in free queue
127
static
int
QuantumMin
;
// aio segment size (Quantum/2)
128
static
int
Quantum
;
// aio segment size
129
static
int
QuantumMax
;
// aio segment size (Quantum*2)
130
static
int
maxAioPR
;
// aio objects per request (max)
131
static
int
maxAioPR2
;
// aio objects per request (max*2)
132
133
XrdSysMutex
aioMutex
;
// Locks private data
134
XrdXrootdAioReq
*
Next
;
// -> Chain pointer
135
136
off_t
myOffset
;
// Next offset (used for read's only)
137
int
myIOLen
;
// Size remaining (read and write end)
138
unsigned
int
Instance
;
// Network Link Instance
139
XrdLink
*
Link
;
// -> Network link
140
XrdXrootdFile
*
myFile
;
// -> Associated file
141
142
XrdXrootdAio
*
aioDone
;
// Next aiocb that completed
143
XrdXrootdAio
*
aioFree
;
// Next aiocb that we can use
144
int
numActive
;
// Number of aio requests outstanding
145
int
aioTotal
;
// Actual number of disk bytes transferred
146
int
aioError
;
// First errno encounetered
147
char
aioType
;
// 'r' or 'w' or 's'
148
char
respDone
;
// 1 -> Response has been sent
149
char
isLocked
;
// 1 -> Object lock being held
150
char
reDrive
;
// 1 -> Link redrive is needed
151
152
XrdXrootdResponse
Response
;
// Copy of the original response object
153
};
154
#endif
Generated by
1.8.1.2