Loading...
Searching...
No Matches
XrdOssCsiFileAio.cc
Go to the documentation of this file.
/******************************************************************************/
/* */
/* X r d O s s C s i F i l e A i o . c c */
/* */
/* (C) Copyright 2021 CERN. */
/* */
/* 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. */
/* */
/* In applying this licence, CERN does not waive the privileges and */
/* immunities granted to it by virtue of its status as an Intergovernmental */
/* Organization or submit itself to any jurisdiction. */
/* */
/* 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 "XrdOssCsiTrace.hh"
#include "XrdOssCsi.hh"
#include "XrdOssCsiPages.hh"
#include "XrdOssCsiFileAio.hh"
#include "XrdOuc/XrdOucCRC.hh"
#include <string>
#include <algorithm>
#include <mutex>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
extern XrdOucTrace OssCsiTrace;
XrdOssCsiFileAioStore::~XrdOssCsiFileAioStore()
{
XrdOssCsiFileAio *p;
while((p=list_))
{
list_ = list_->next_;
delete p;
}
}
int XrdOssCsiFile::Read(XrdSfsAio *aiop)
{
if (!pmi_) return -EBADF;
XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
nio->Init(aiop, this, false, 0, true);
nio->SchedReadJob();
return 0;
}
int XrdOssCsiFile::Write(XrdSfsAio *aiop)
{
if (!pmi_) return -EBADF;
if (rdonly_) return -EBADF;
XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
nio->Init(aiop, this, false, 0, false);
// pages will be locked when write is scheduled
nio->SchedWriteJob();
return 0;
}
int XrdOssCsiFile::pgRead(XrdSfsAio *aioparm, uint64_t opts)
{
if (!pmi_) return -EBADF;
XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
nio->Init(aioparm, this, true, opts, true);
nio->SchedReadJob();
return 0;
}
int XrdOssCsiFile::pgWrite(XrdSfsAio *aioparm, uint64_t opts)
{
if (!pmi_) return -EBADF;
if (rdonly_) return -EBADF;
uint64_t pgopts = opts;
const int prec = XrdOssCsiPages::pgWritePrelockCheck(
(void *)aioparm->sfsAio.aio_buf,
(off_t)aioparm->sfsAio.aio_offset,
(size_t)aioparm->sfsAio.aio_nbytes,
aioparm->cksVec,
opts);
if (prec < 0)
{
return prec;
}
XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
nio->Init(aioparm, this, true, pgopts, false);
// pages will be locked when write is scheduled
nio->SchedWriteJob();
return 0;
}
int XrdOssCsiFile::Fsync(XrdSfsAio *aiop)
{
aioWait();
aiop->Result = this->Fsync();
aiop->doneWrite();
return 0;
}
OssCsiTrace
XrdOucTrace OssCsiTrace
XrdOssCsiFileAio.hh
XrdOssCsiPages.hh
XrdOssCsiTrace.hh
XrdOssCsi.hh
XrdOucCRC.hh
opts
struct myOpts opts
aiocb::aio_offset
off_t aio_offset
Definition XrdSfsAio.hh:49
aiocb::aio_nbytes
size_t aio_nbytes
Definition XrdSfsAio.hh:48
aiocb::aio_buf
void * aio_buf
Definition XrdSfsAio.hh:47
XrdOssCsiFileAioStore::~XrdOssCsiFileAioStore
~XrdOssCsiFileAioStore()
Definition XrdOssCsiFileAio.cc:49
XrdOssCsiFileAioStore::list_
XrdOssCsiFileAio * list_
Definition XrdOssCsi.hh:53
XrdOssCsiFileAio
Definition XrdOssCsiFileAio.hh:110
XrdOssCsiFileAio::SchedReadJob
void SchedReadJob()
Definition XrdOssCsiFileAio.hh:200
XrdOssCsiFileAio::SchedWriteJob
void SchedWriteJob()
Definition XrdOssCsiFileAio.hh:189
XrdOssCsiFileAio::Alloc
static XrdOssCsiFileAio * Alloc(XrdOssCsiFileAioStore *store)
Definition XrdOssCsiFileAio.hh:171
XrdOssCsiFileAio::Init
void Init(XrdSfsAio *aiop, XrdOssCsiFile *file, bool isPgOp, uint64_t opts, bool isread)
Definition XrdOssCsiFileAio.hh:153
XrdOssCsiFile::pgWrite
virtual ssize_t pgWrite(void *, off_t, size_t, uint32_t *, uint64_t)
Definition XrdOssCsiFile.cc:503
XrdOssCsiFile::Fsync
virtual int Fsync()
Definition XrdOssCsiFile.cc:542
XrdOssCsiFile::Write
virtual ssize_t Write(const void *, off_t, size_t)
Definition XrdOssCsiFile.cc:404
XrdOssCsiFile::pgRead
virtual ssize_t pgRead(void *, off_t, size_t, uint32_t *, uint64_t)
Definition XrdOssCsiFile.cc:475
XrdOssCsiFile::Read
virtual ssize_t Read(off_t, size_t)
Definition XrdOssCsiFile.cc:340
XrdOssCsiFile::XrdOssCsiFileAio
friend class XrdOssCsiFileAio
Definition XrdOssCsi.hh:75
XrdOssCsiFile::aioWait
void aioWait()
Definition XrdOssCsi.hh:126
XrdOssCsiPages::pgWritePrelockCheck
static int pgWritePrelockCheck(const void *, off_t, size_t, const uint32_t *, uint64_t)
Definition XrdOssCsiPages.cc:788
XrdOucTrace
Definition XrdOucTrace.hh:36
XrdSfsAio
Definition XrdSfsAio.hh:59
XrdSfsAio::cksVec
uint32_t * cksVec
Definition XrdSfsAio.hh:63
XrdSfsAio::Result
ssize_t Result
Definition XrdSfsAio.hh:65
XrdSfsAio::sfsAio
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
XrdSfsAio::doneWrite
virtual void doneWrite()=0