XRootD
Loading...
Searching...
No Matches
XrdXrootdAioTask.hh
Go to the documentation of this file.
1#ifndef __XRDXROOTDAIOTASK_H__
2#define __XRDXROOTDAIOTASK_H__
3/******************************************************************************/
4/* */
5/* X r d X r o o t d A i o T a s k . h h */
6/* */
7/* (c) 2021 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 "Xrd/XrdJob.hh"
37
38using namespace XrdSys;
39
40class XrdLink;
44class XrdXrootdFile;
45
46class XrdXrootdAioTask : public XrdJob, public XrdXrootdProtocol::gdCallBack
47{
48public:
49friend class XrdXrootdAioFob;
50
51 void Completed(XrdXrootdAioBuff *aioP);
52
53 const char *ID();
54
55 void Init(XrdXrootdProtocol *protP,
57 XrdXrootdFile *fP);
58
59virtual void Read(long long offs, int dlen) = 0;
60
61virtual void Recycle(bool release) = 0;
62
64
65virtual int Write(long long offs, int dlen) = 0;
66
67protected:
68
69 XrdXrootdAioTask(const char *what="aio request")
70 : XrdJob(what), aioReady(aioMutex) {}
72
73virtual void CopyF2L() = 0;
74virtual int CopyL2F() = 0;
75virtual bool CopyL2F(XrdXrootdAioBuff *aioP) = 0;
76 bool Drain();
77 int gdDone() override;
78 void gdFail() override;
79 XrdXrootdAioBuff* getBuff(bool wait);
80 void SendError(int rc, const char *eText);
81 void SendFSError(int rc);
82 bool Validate(XrdXrootdAioBuff* aioP);
83
84static const char* TraceID;
85
86 XrdSysMutex aioMutex; // Locks private data
89 XrdXrootdAioBuff* pendQEnd; // -> Last element in pendQ
90
91union {XrdXrootdNormAio* nextNorm; // Never used in conflicting context!
92 XrdXrootdPgrwAio* nextPgrw;
93 XrdXrootdAioTask* nextTask;
94 };
95
96 XrdXrootdProtocol* Protocol; // -> Protocol associated with dataLink
97 XrdLink* dataLink; // -> Network link
98 XrdXrootdFile* dataFile; // -> Associated file
99union {XrdXrootdAioBuff *finalRead; // -> A short read indicating EOF
100 XrdXrootdAioBuff *pendWrite; // -> Pending write operation
101 };
102 off_t highOffset; // F2L: EOF offset L2F: initial offset
103 off_t dataOffset; // Next offset
104 int dataLen; // Size remaining
105
106 char aioState; // See aioXXX below
108 RAtomic_bool isDone; // Request finished
109 char Status; // Offline | Running | Waiting
110
112
113// These values may be present in aioState
114//
115static const int aioDead = 0x01; // This aio encountered a fatal link error
116static const int aioHeld = 0x02; // This aio is recycled but held
117static const int aioPage = 0x04; // This read is a pgread
118static const int aioRead = 0x08; // This is a read (i.e. File to Link copy)
119static const int aioSchd = 0x10; // Next read has been scheduled
120
121// These must be inspected or set with aioMutex held
122//
123static const int Offline = 0; // Needs to be rescheduled (read only)
124static const int Running = 1; // Executing
125static const int Waiting = 2; // Waiting for buffer needs to be signaled
126
127private:
128
129 bool Wait4Buff(int maxWait=0);
130};
131#endif
virtual void Read(long long offs, int dlen)=0
XrdSysCondVar2 aioReady
static const int aioPage
static const int Offline
int gdDone() override
static const int Waiting
virtual void Recycle(bool release)=0
virtual int CopyL2F()=0
XrdXrootdFile * dataFile
virtual ~XrdXrootdAioTask()
bool Validate(XrdXrootdAioBuff *aioP)
virtual int Write(long long offs, int dlen)=0
XrdXrootdAioBuff * pendQ
XrdXrootdAioBuff * getBuff(bool wait)
void SendError(int rc, const char *eText)
void Completed(XrdXrootdAioBuff *aioP)
XrdXrootdResponse Response
static const int Running
void Init(XrdXrootdProtocol *protP, XrdXrootdResponse &resp, XrdXrootdFile *fP)
virtual bool CopyL2F(XrdXrootdAioBuff *aioP)=0
void SendFSError(int rc)
XrdXrootdAioBuff * pendQEnd
virtual void CopyF2L()=0
static const int aioRead
XrdXrootdAioTask(const char *what="aio request")
static const int aioSchd
static const char * TraceID
void gdFail() override
static const int aioHeld
RAtomic_uchar inFlight
XrdXrootdProtocol * urProtocol()
static const int aioDead
XrdXrootdProtocol * Protocol