Loading...
Searching...
No Matches
XrdXrootdAioTask.hh
Go to the documentation of this file.
#ifndef __XRDXROOTDAIOTASK_H__
#define __XRDXROOTDAIOTASK_H__
/******************************************************************************/
/* */
/* X r d X r o o t d A i o T a s k . h h */
/* */
/* (c) 2021 by the Board of Trustees of the Leland Stanford, Jr., University */
/* All Rights Reserved */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include "Xrd/XrdJob.hh"
#include "XrdXrootd/XrdXrootdProtocol.hh"
#include "XrdSys/XrdSysPthread.hh"
#include "XrdSys/XrdSysRAtomic.hh"
using namespace XrdSys;
class XrdLink;
class XrdXrootdAioBuff;
class XrdXrootdNormAio;
class XrdXrootdPgrwAio;
class XrdXrootdFile;
class XrdXrootdAioTask : public XrdJob, public XrdXrootdProtocol::gdCallBack
{
public:
friend class XrdXrootdAioFob;
void Completed(XrdXrootdAioBuff *aioP);
const char *ID();
void Init(XrdXrootdProtocol *protP,
XrdXrootdResponse &resp,
XrdXrootdFile *fP);
virtual void Read(long long offs, int dlen) = 0;
virtual void Recycle(bool release) = 0;
XrdXrootdProtocol *urProtocol() {return Protocol;}
virtual int Write(long long offs, int dlen) = 0;
protected:
XrdXrootdAioTask(const char *what="aio request")
: XrdJob(what), aioReady(aioMutex) {}
virtual ~XrdXrootdAioTask() {}
virtual void CopyF2L() = 0;
virtual int CopyL2F() = 0;
virtual bool CopyL2F(XrdXrootdAioBuff *aioP) = 0;
bool Drain();
int gdDone() override;
void gdFail() override;
XrdXrootdAioBuff* getBuff(bool wait);
void SendError(int rc, const char *eText);
void SendFSError(int rc);
bool Validate(XrdXrootdAioBuff* aioP);
static const char* TraceID;
XrdSysMutex aioMutex; // Locks private data
XrdSysCondVar2 aioReady;
XrdXrootdAioBuff* pendQ;
XrdXrootdAioBuff* pendQEnd; // -> Last element in pendQ
union {XrdXrootdNormAio* nextNorm; // Never used in conflicting context!
XrdXrootdPgrwAio* nextPgrw;
XrdXrootdAioTask* nextTask;
};
XrdXrootdProtocol* Protocol; // -> Protocol associated with dataLink
XrdLink* dataLink; // -> Network link
XrdXrootdFile* dataFile; // -> Associated file
union {XrdXrootdAioBuff *finalRead; // -> A short read indicating EOF
XrdXrootdAioBuff *pendWrite; // -> Pending write operation
};
off_t highOffset; // F2L: EOF offset L2F: initial offset
off_t dataOffset; // Next offset
int dataLen; // Size remaining
char aioState; // See aioXXX below
RAtomic_uchar inFlight;
RAtomic_bool isDone; // Request finished
char Status; // Offline | Running | Waiting
XrdXrootdResponse Response;
// These values may be present in aioState
//
static const int aioDead = 0x01; // This aio encountered a fatal link error
static const int aioHeld = 0x02; // This aio is recycled but held
static const int aioPage = 0x04; // This read is a pgread
static const int aioRead = 0x08; // This is a read (i.e. File to Link copy)
static const int aioSchd = 0x10; // Next read has been scheduled
// These must be inspected or set with aioMutex held
//
static const int Offline = 0; // Needs to be rescheduled (read only)
static const int Running = 1; // Executing
static const int Waiting = 2; // Waiting for buffer needs to be signaled
private:
bool Wait4Buff(int maxWait=0);
};
#endif
XrdJob.hh
XrdSysPthread.hh
XrdSysRAtomic.hh
RAtomic_uchar
XrdSys::RAtomic< unsigned char > RAtomic_uchar
Definition XrdSysRAtomic.hh:322
RAtomic_bool
XrdSys::RAtomic< bool > RAtomic_bool
Definition XrdSysRAtomic.hh:319
XrdXrootdProtocol.hh
XrdJob::XrdJob
XrdJob(const char *desc="")
Definition XrdJob.hh:51
XrdLink
Definition XrdLink.hh:52
XrdSysCondVar2
Definition XrdSysPthread.hh:300
XrdSysMutex
Definition XrdSysPthread.hh:165
XrdXrootdAioBuff
Definition XrdXrootdAioBuff.hh:41
XrdXrootdAioTask::Read
virtual void Read(long long offs, int dlen)=0
XrdXrootdAioTask::dataLen
int dataLen
Definition XrdXrootdAioTask.hh:104
XrdXrootdAioTask::aioReady
XrdSysCondVar2 aioReady
Definition XrdXrootdAioTask.hh:87
XrdXrootdAioTask::aioPage
static const int aioPage
Definition XrdXrootdAioTask.hh:117
XrdXrootdAioTask::Offline
static const int Offline
Definition XrdXrootdAioTask.hh:123
XrdXrootdAioTask::gdDone
int gdDone() override
Definition XrdXrootdAioTask.cc:157
XrdXrootdAioTask::Waiting
static const int Waiting
Definition XrdXrootdAioTask.hh:125
XrdXrootdAioTask::Recycle
virtual void Recycle(bool release)=0
XrdXrootdAioTask::dataLink
XrdLink * dataLink
Definition XrdXrootdAioTask.hh:97
XrdXrootdAioTask::isDone
RAtomic_bool isDone
Definition XrdXrootdAioTask.hh:108
XrdXrootdAioTask::CopyL2F
virtual int CopyL2F()=0
XrdXrootdAioTask::dataFile
XrdXrootdFile * dataFile
Definition XrdXrootdAioTask.hh:98
XrdXrootdAioTask::~XrdXrootdAioTask
virtual ~XrdXrootdAioTask()
Definition XrdXrootdAioTask.hh:71
XrdXrootdAioTask::Status
char Status
Definition XrdXrootdAioTask.hh:109
XrdXrootdAioTask::Validate
bool Validate(XrdXrootdAioBuff *aioP)
Definition XrdXrootdAioTask.cc:366
XrdXrootdAioTask::aioMutex
XrdSysMutex aioMutex
Definition XrdXrootdAioTask.hh:86
XrdXrootdAioTask::Write
virtual int Write(long long offs, int dlen)=0
XrdXrootdAioTask::XrdXrootdAioFob
friend class XrdXrootdAioFob
Definition XrdXrootdAioTask.hh:49
XrdXrootdAioTask::pendQ
XrdXrootdAioBuff * pendQ
Definition XrdXrootdAioTask.hh:88
XrdXrootdAioTask::getBuff
XrdXrootdAioBuff * getBuff(bool wait)
Definition XrdXrootdAioTask.cc:232
XrdXrootdAioTask::aioState
char aioState
Definition XrdXrootdAioTask.hh:106
XrdXrootdAioTask::SendError
void SendError(int rc, const char *eText)
Definition XrdXrootdAioTask.cc:298
XrdXrootdAioTask::Completed
void Completed(XrdXrootdAioBuff *aioP)
Definition XrdXrootdAioTask.cc:73
XrdXrootdAioTask::Response
XrdXrootdResponse Response
Definition XrdXrootdAioTask.hh:111
XrdXrootdAioTask::Running
static const int Running
Definition XrdXrootdAioTask.hh:124
XrdXrootdAioTask::Init
void Init(XrdXrootdProtocol *protP, XrdXrootdResponse &resp, XrdXrootdFile *fP)
Definition XrdXrootdAioTask.cc:275
XrdXrootdAioTask::CopyL2F
virtual bool CopyL2F(XrdXrootdAioBuff *aioP)=0
XrdXrootdAioTask::SendFSError
void SendFSError(int rc)
Definition XrdXrootdAioTask.cc:328
XrdXrootdAioTask::Drain
bool Drain()
Definition XrdXrootdAioTask.cc:113
XrdXrootdAioTask::pendQEnd
XrdXrootdAioBuff * pendQEnd
Definition XrdXrootdAioTask.hh:89
XrdXrootdAioTask::highOffset
off_t highOffset
Definition XrdXrootdAioTask.hh:102
XrdXrootdAioTask::CopyF2L
virtual void CopyF2L()=0
XrdXrootdAioTask::aioRead
static const int aioRead
Definition XrdXrootdAioTask.hh:118
XrdXrootdAioTask::ID
const char * ID()
Definition XrdXrootdAioTask.cc:269
XrdXrootdAioTask::XrdXrootdAioTask
XrdXrootdAioTask(const char *what="aio request")
Definition XrdXrootdAioTask.hh:69
XrdXrootdAioTask::aioSchd
static const int aioSchd
Definition XrdXrootdAioTask.hh:119
XrdXrootdAioTask::TraceID
static const char * TraceID
Definition XrdXrootdAioTask.hh:84
XrdXrootdAioTask::gdFail
void gdFail() override
Definition XrdXrootdAioTask.cc:198
XrdXrootdAioTask::dataOffset
off_t dataOffset
Definition XrdXrootdAioTask.hh:103
XrdXrootdAioTask::aioHeld
static const int aioHeld
Definition XrdXrootdAioTask.hh:116
XrdXrootdAioTask::inFlight
RAtomic_uchar inFlight
Definition XrdXrootdAioTask.hh:107
XrdXrootdAioTask::urProtocol
XrdXrootdProtocol * urProtocol()
Definition XrdXrootdAioTask.hh:63
XrdXrootdAioTask::aioDead
static const int aioDead
Definition XrdXrootdAioTask.hh:115
XrdXrootdAioTask::Protocol
XrdXrootdProtocol * Protocol
Definition XrdXrootdAioTask.hh:96
XrdXrootdFile
Definition XrdXrootdFile.hh:101
XrdXrootdNormAio
Definition XrdXrootdNormAio.hh:39
XrdXrootdPgrwAio
Definition XrdXrootdPgrwAio.hh:39
XrdXrootdProtocol
Definition XrdXrootdProtocol.hh:160
XrdXrootdResponse
Definition XrdXrootdResponse.hh:49
XrdSys
Definition XrdClPollerBuiltIn.hh:28