XRootD
Loading...
Searching...
No Matches
XrdXrootdAioFob.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d X r o o t d A i o F o b . h h */
4/* */
5/* (c) 2021 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 "Xrd/XrdLink.hh"
31#include "Xrd/XrdScheduler.hh"
36
37#define TRACELINK aioP->dataLink
38
39/******************************************************************************/
40/* G l o b a l S t a t i c s */
41/******************************************************************************/
42
43namespace
44{
45const char *TraceID = "AioFob";
46}
47
49
50namespace XrdXrootd
51{
52extern XrdSysError eLog;
53extern XrdScheduler *Sched;
54}
55using namespace XrdXrootd;
56
57/******************************************************************************/
58/* N o t i f y */
59/******************************************************************************/
60
61void XrdXrootdAioFob::Notify(XrdXrootdAioTask *aioP, const char *what)
62{
63 TRACEI(FSAIO, what<<" aio "
64 <<(aioP->aioState & XrdXrootdAioTask::aioPage ? "pgread " : "read ")
65 <<aioP->dataLen<<'@'<<aioP->dataOffset<< " for "
66 <<aioP->dataFile->FileKey);
67}
68
69/******************************************************************************/
70/* R e s e t */
71/******************************************************************************/
72
74{
75 XrdXrootdAioTask *aioP;
76
77// Recycle all outstanding aio tasks
78//
79 fobMutex.Lock();
80
81 for (int i = 0; i < maxQ; i++)
82 {while((aioP = aioQ[i].first))
83 {aioQ[i].first = aioP->nextTask;
84 if (TRACING(TRACE_FSAIO)) Notify(aioP, "Discarding");
85 aioP->Recycle(true);
86 }
87 aioQ[i].last = 0;
88 Running[i] = false;
89 }
90
91 fobMutex.UnLock();
92}
93
94/******************************************************************************/
95
97{
98 XrdXrootdAioTask *aioP;
99 int pathID = protP->getPathID();
100
101// Recycle all outstanding aio tasks
102//
103 fobMutex.Lock();
104
105 while((aioP = aioQ[pathID].first))
106 {aioQ[pathID].first = aioP->nextTask;
107 if (TRACING(TRACE_FSAIO)) Notify(aioP, "Discarding");
108 aioP->Recycle(true);
109 }
110 aioQ[pathID].last = 0;
111 Running[pathID] = false;
112
113 fobMutex.UnLock();
114}
115
116/******************************************************************************/
117/* S c h e d u l e */
118/******************************************************************************/
119
121{
122 int pathID = aioP->Protocol->getPathID();
123
124// Run or queue this task
125//
126 fobMutex.Lock();
127
128 if (Running[pathID])
129 {if (aioQ[pathID].last) aioQ[pathID].last->nextTask = aioP;
130 else aioQ[pathID].first = aioP;
131 aioQ[pathID].last = aioP;
132 aioP->nextTask = 0;
133 if (maxQ <= pathID) maxQ = pathID+1;
134 if (TRACING(TRACE_FSAIO)) Notify(aioP, "Queuing");
135 } else {
136 Sched->Schedule(aioP);
137 Running[pathID] = true;
138 if (TRACING(TRACE_FSAIO)) Notify(aioP, "Running");
139 }
140
141 fobMutex.UnLock();
142}
143
144/******************************************************************************/
145
147{
148 int pathID = protP->getPathID();
149
150// Schedule the next task.
151//
152 fobMutex.Lock();
153
154 if (aioQ[pathID].first)
155 {XrdXrootdAioTask *aioP = aioQ[pathID].first;
156 if (!(aioQ[pathID].first = aioP->nextTask)) aioQ[pathID].last = 0;
157 aioP->nextTask = 0;
158 Sched->Schedule(aioP);
159 Running[pathID] = true;
160 if (TRACING(TRACE_FSAIO)) Notify(aioP, "Running");
161 } else Running[pathID] = false;
162
163 fobMutex.UnLock();
164}
#define TRACING(x)
Definition XrdTrace.hh:70
#define TRACEI(act, x)
Definition XrdTrace.hh:66
XrdSysTrace XrdXrootdTrace
#define TRACE_FSAIO
void Schedule(XrdJob *jp)
void Schedule(XrdXrootdAioTask *aioP)
static const int aioPage
virtual void Recycle(bool release)=0
XrdXrootdProtocol * Protocol
XrdScheduler * Sched
XrdSysError eLog