XRootD
XrdOssCsiFile Class Reference

#include <XrdOssCsi.hh>

+ Inheritance diagram for XrdOssCsiFile:
+ Collaboration diagram for XrdOssCsiFile:

Classes

struct  puMapItem_t
 

Public Member Functions

 XrdOssCsiFile (XrdOss *parent, const char *tid, XrdOssCsiConfig &cf)
 
virtual ~XrdOssCsiFile ()
 
void aioDec ()
 
void aioInc ()
 
void aioWait ()
 
virtual int Close (long long *retsz=0)
 
virtual void Flush ()
 Flush filesystem cached pages for this file (used for checksums). More...
 
virtual int Fstat (struct stat *)
 
virtual int Fsync ()
 
virtual int Fsync (XrdSfsAio *)
 
virtual int Ftruncate (unsigned long long)
 
virtual int getFD ()
 
virtual off_t getMmap (void **addr)
 
virtual int Open (const char *, int, mode_t, XrdOucEnv &)
 
XrdOssCsiPagesPages ()
 
virtual ssize_t pgRead (void *, off_t, size_t, uint32_t *, uint64_t)
 
virtual int pgRead (XrdSfsAio *, uint64_t)
 
virtual ssize_t pgWrite (void *, off_t, size_t, uint32_t *, uint64_t)
 
virtual int pgWrite (XrdSfsAio *, uint64_t)
 
virtual ssize_t Read (off_t, size_t)
 
virtual ssize_t Read (void *, off_t, size_t)
 
virtual int Read (XrdSfsAio *)
 
virtual ssize_t ReadRaw (void *, off_t, size_t)
 
virtual ssize_t ReadV (XrdOucIOVec *readV, int n)
 
int VerificationStatus ()
 
virtual ssize_t Write (const void *, off_t, size_t)
 
virtual int Write (XrdSfsAio *)
 
virtual ssize_t WriteV (XrdOucIOVec *writeV, int n)
 
- Public Member Functions inherited from XrdOssDFHandler
 XrdOssDFHandler (XrdOssDF *successor)
 
virtual ~XrdOssDFHandler ()
 
virtual int Fchmod (mode_t Mode)
 
virtual int Fctl (int cmd, int alen, const char *args, char **resp=0)
 
virtual const char * getTID ()
 
virtual int isCompressed (char *cxidp=0)
 
virtual int Opendir (const char *dir_path, XrdOucEnv &Env)
 
virtual int Readdir (char *buff, int blen)
 
virtual int StatRet (struct stat *buff)
 
- Public Member Functions inherited from XrdOssDF
 XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
 
virtual ~XrdOssDF ()
 
uint16_t DFType ()
 

Static Public Member Functions

static int mapRelease (std::shared_ptr< puMapItem_t > &, XrdSysMutexHelper *plck=NULL)
 
static void mapTake (const std::string &, std::shared_ptr< puMapItem_t > &, bool create=true)
 

Static Public Attributes

static std::unordered_map< std::string, std::shared_ptr< puMapItem_t > > pumap_
 
static XrdSysMutex pumtx_
 
- Static Public Attributes inherited from XrdOssDF
static const uint16_t DF_isDir = 0x0001
 Object is for a directory. More...
 
static const uint16_t DF_isFile = 0x0002
 Object is for a file. More...
 
static const uint16_t DF_isProxy = 0x0010
 Object is a proxy object. More...
 
static const uint64_t doCalc = 0x4000000000000000ULL
 pgw: Calculate checksums More...
 
static const int Fctl_ckpObj = 0
 
static const int Fctl_utimes = 1
 
static const uint64_t Verify = 0x8000000000000000ULL
 all: Verify checksums More...
 

Friends

class XrdOssCsiFileAio
 
class XrdOssCsiFileAioJob
 

Additional Inherited Members

- Protected Attributes inherited from XrdOssDFHandler
XrdOssDFsuccessor_
 
- Protected Attributes inherited from XrdOssDF
uint16_t dfType
 
int fd
 
off_t pgwEOF
 
short rsvd
 
const char * tident
 

Detailed Description

Definition at line 73 of file XrdOssCsi.hh.

Constructor & Destructor Documentation

◆ XrdOssCsiFile()

XrdOssCsiFile::XrdOssCsiFile ( XrdOss parent,
const char *  tid,
XrdOssCsiConfig cf 
)
inline

Definition at line 106 of file XrdOssCsi.hh.

106  :
107  XrdOssDFHandler(parent->newFile(tid)), parentOss_(parent), tident(tid), config_(cf),
108  rdonly_(false), aioCntCond_(0), aioCnt_(0), aioCntWaiters_(0) { }
static void parent()
XrdOssDFHandler(XrdOssDF *successor)

◆ ~XrdOssCsiFile()

XrdOssCsiFile::~XrdOssCsiFile ( )
virtual

Definition at line 178 of file XrdOssCsiFile.cc.

179 {
180  if (pmi_)
181  {
182  (void)Close();
183  }
184 }
virtual int Close(long long *retsz=0)

References Close().

+ Here is the call graph for this function:

Member Function Documentation

◆ aioDec()

void XrdOssCsiFile::aioDec ( )
inline

Definition at line 120 of file XrdOssCsi.hh.

121  {
122  XrdSysCondVarHelper lck(&aioCntCond_);
123  if (--aioCnt_ == 0 && aioCntWaiters_>0)
124  aioCntCond_.Broadcast();
125  }

References XrdSysCondVar::Broadcast().

Referenced by XrdOssCsiFileAio::Recycle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aioInc()

void XrdOssCsiFile::aioInc ( )
inline

Definition at line 111 of file XrdOssCsi.hh.

112  {
113  XrdSysCondVarHelper lck(&aioCntCond_);
114  while(aioCntWaiters_>0)
115  {
116  aioCntCond_.Wait();
117  }
118  ++aioCnt_;
119  }

References XrdSysCondVar::Wait().

Referenced by XrdOssCsiFileAio::Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aioWait()

void XrdOssCsiFile::aioWait ( )
inline

Definition at line 126 of file XrdOssCsi.hh.

127  {
128  XrdSysCondVarHelper lck(&aioCntCond_);
129  ++aioCntWaiters_;
130  while(aioCnt_>0)
131  {
132  aioCntCond_.Wait();
133  }
134  --aioCntWaiters_;
135  aioCntCond_.Broadcast();
136  }

References XrdSysCondVar::Broadcast(), and XrdSysCondVar::Wait().

Referenced by Close(), and Fsync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Close()

int XrdOssCsiFile::Close ( long long *  retsz = 0)
virtual

Close a directory or file.

Parameters
retszIf not nil, where the size of the file is to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 186 of file XrdOssCsiFile.cc.

187 {
188  if (!pmi_)
189  {
190  return -EBADF;
191  }
192 
193  // wait for any ongoing aios to finish
194  aioWait();
195 
196  const int cpret = pageMapClose();
197 
198  const int csret = successor_->Close(retsz);
199  if (cpret<0) return cpret;
200  return csret;
201 }
void aioWait()
Definition: XrdOssCsi.hh:126
XrdOssDF * successor_
virtual int Close(long long *retsz=0)=0

References aioWait(), XrdOssDF::Close(), and XrdOssDFHandler::successor_.

Referenced by ~XrdOssCsiFile(), and Open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Flush()

void XrdOssCsiFile::Flush ( )
virtual

Flush filesystem cached pages for this file (used for checksums).

Reimplemented from XrdOssDFHandler.

Definition at line 598 of file XrdOssCsiFile.cc.

599 {
600  if (!pmi_) return;
601 
602  Pages()->Flush();
603  successor_->Flush();
604 }
XrdOssCsiPages * Pages()
Definition: XrdOssCsi.hh:140
virtual void Flush()
Flush filesystem cached pages for this file (used for checksums).
Definition: XrdOss.hh:126

References XrdOssDF::Flush(), XrdOssCsiPages::Flush(), Pages(), and XrdOssDFHandler::successor_.

+ Here is the call graph for this function:

◆ Fstat()

int XrdOssCsiFile::Fstat ( struct stat buf)
virtual

Return state information for this file.

Parameters
buf- Pointer to the structure where info it to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 575 of file XrdOssCsiFile.cc.

576 {
577  if (!pmi_) return -EBADF;
579  const int tsret = Pages()->TrackedSizesGet(sizes, false);
580  const int fsret = successor_->Fstat(buff);
581  if (fsret<0) return fsret;
582  if (tsret<0) return 0;
583  buff->st_size = std::max(sizes.first, sizes.second);
584  return 0;
585 }
std::pair< off_t, off_t > Sizes_t
int TrackedSizesGet(Sizes_t &, bool)
virtual int Fstat(struct stat *buf)
Definition: XrdOss.hh:136

References XrdOssDF::Fstat(), Pages(), XrdOssDFHandler::successor_, and XrdOssCsiPages::TrackedSizesGet().

+ Here is the call graph for this function:

◆ Fsync() [1/2]

int XrdOssCsiFile::Fsync ( void  )
virtual

Synchronize associated file with media (synchronous).

Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 542 of file XrdOssCsiFile.cc.

543 {
544  if (!pmi_) return -EBADF;
545 
546  const int psret = Pages()->Fsync();
547  const int ssret = successor_->Fsync();
548  if (psret<0) return psret;
549  return ssret;
550 }
virtual int Fsync()
Definition: XrdOss.hh:144

References XrdOssDF::Fsync(), XrdOssCsiPages::Fsync(), Pages(), and XrdOssDFHandler::successor_.

Referenced by Fsync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Fsync() [2/2]

int XrdOssCsiFile::Fsync ( XrdSfsAio aiop)
virtual

Synchronize associated file with media (asynchronous).

Parameters
aiop- Pointer to async I/O request object.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 115 of file XrdOssCsiFileAio.cc.

116 {
117  aioWait();
118  aiop->Result = this->Fsync();
119  aiop->doneWrite();
120  return 0;
121 }
virtual int Fsync()
ssize_t Result
Definition: XrdSfsAio.hh:65
virtual void doneWrite()=0

References aioWait(), XrdSfsAio::doneWrite(), Fsync(), and XrdSfsAio::Result.

+ Here is the call graph for this function:

◆ Ftruncate()

int XrdOssCsiFile::Ftruncate ( unsigned long long  flen)
virtual

Set the size of the associated file.

Parameters
flen- The new size of the file.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 552 of file XrdOssCsiFile.cc.

553 {
554  if (!pmi_) return -EBADF;
555  if (rdonly_) return -EBADF;
556 
558  Pages()->LockTrackinglen(rg, flen, LLONG_MAX, false);
559  int ret = Pages()->truncate(successor_, flen, rg);
560  if (ret<0)
561  {
562  rg.ReleaseAll();
563  resyncSizes();
564  return ret;
565  }
566  ret = successor_->Ftruncate(flen);
567  if (ret<0)
568  {
569  rg.ReleaseAll();
570  resyncSizes();
571  }
572  return ret;
573 }
int truncate(XrdOssDF *, off_t, XrdOssCsiRangeGuard &)
void LockTrackinglen(XrdOssCsiRangeGuard &, off_t, off_t, bool)
virtual int Ftruncate(unsigned long long flen)
Definition: XrdOss.hh:164

References XrdOssDF::Ftruncate(), XrdOssCsiPages::LockTrackinglen(), Pages(), XrdOssCsiRangeGuard::ReleaseAll(), XrdOssDFHandler::successor_, and XrdOssCsiPages::truncate().

+ Here is the call graph for this function:

◆ getFD()

virtual int XrdOssCsiFile::getFD ( )
inlinevirtual

Return the underlying file descriptor.

Returns
-1 if there is no file descriptor or a non-negative FD number.

Reimplemented from XrdOssDFHandler.

Definition at line 83 of file XrdOssCsi.hh.

83 { return -1; }

◆ getMmap()

virtual off_t XrdOssCsiFile::getMmap ( void **  addr)
inlinevirtual

Return the memory mapped characteristics of the file.

Parameters
addr- Pointer to where the memory mapped address is to be returned.
Returns
If mapped, the size of the file is returned and it memory location is placed in addr. Otherwise, addr is set to zero and zero is returned. Note that zero length files cannot be memory mapped.

Reimplemented from XrdOssDFHandler.

Definition at line 82 of file XrdOssCsi.hh.

82 { if (addr) *addr = 0; return 0; }

◆ mapRelease()

int XrdOssCsiFile::mapRelease ( std::shared_ptr< puMapItem_t > &  pmi,
XrdSysMutexHelper plck = NULL 
)
static

Definition at line 109 of file XrdOssCsiFile.cc.

110 {
112  pmi->refcount--;
113  auto mapidx = pumap_.find(pmi->tpath);
114  if (pmi->refcount == 0 || pmi->unlinked)
115  {
116  if (mapidx != pumap_.end() && mapidx->second == pmi)
117  {
118  pumap_.erase(mapidx);
119  }
120  }
121  if (plck) plck->UnLock();
122  return (pmi->refcount == 0) ? 1 : 0;
123 }
static XrdSysMutex pumtx_
Definition: XrdOssCsi.hh:159
static std::unordered_map< std::string, std::shared_ptr< puMapItem_t > > pumap_
Definition: XrdOssCsi.hh:160

References pumap_, pumtx_, and XrdSysMutexHelper::UnLock().

Referenced by XrdOssCsi::Create(), XrdOssCsi::Rename(), and XrdOssCsi::Unlink().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapTake()

void XrdOssCsiFile::mapTake ( const std::string &  key,
std::shared_ptr< puMapItem_t > &  pmi,
bool  create = true 
)
static

Definition at line 88 of file XrdOssCsiFile.cc.

89 {
91  auto mapidx = pumap_.find(key);
92  if (mapidx == pumap_.end())
93  {
94  if (!create) return;
95  pmi.reset(new puMapItem_t());
96  pmi->tpath = key;
97  if (!key.empty())
98  {
99  pumap_.insert(std::make_pair(key, pmi));
100  }
101  }
102  else
103  {
104  pmi = mapidx->second;
105  }
106  pmi->refcount++;
107 }

References pumap_, and pumtx_.

Referenced by XrdOssCsi::Create(), XrdOssCsi::Rename(), and XrdOssCsi::Unlink().

+ Here is the caller graph for this function:

◆ Open()

int XrdOssCsiFile::Open ( const char *  path,
int  Oflag,
mode_t  Mode,
XrdOucEnv env 
)
virtual

Open a file.

Parameters
path- Pointer to the path of the file to be opened.
Oflag- Standard open flags.
Mode- File open mode (ignored unless creating a file).
env- Reference to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 286 of file XrdOssCsiFile.cc.

287 {
288  char cxid[4];
289 
290  if (pmi_)
291  {
292  // already open
293  return -EINVAL;
294  }
295 
296  if (!path)
297  {
298  return -EINVAL;
299  }
300  if (config_.tagParam_.isTagFile(path))
301  {
302  if ((Oflag & O_CREAT)) return -EACCES;
303  return -ENOENT;
304  }
305 
306  int dflags = Oflag;
307  if ((dflags & O_ACCMODE) == O_WRONLY)
308  {
309  // for non-aligned writes it may be needed to do read-modify-write
310  dflags &= ~O_ACCMODE;
311  dflags |= O_RDWR;
312  }
313 
314  rdonly_ = true;
315  if ((dflags & O_ACCMODE) != O_RDONLY)
316  {
317  rdonly_ = false;
318  }
319 
320  const int oret = pageAndFileOpen(path, dflags, Oflag, Mode, Env);
321  if (oret<0)
322  {
323  return oret;
324  }
325 
326  if (successor_->isCompressed(cxid)>0)
327  {
328  (void)Close();
329  return -ENOTSUP;
330  }
331 
332  if (Pages()->IsReadOnly() && !rdonly_)
333  {
334  (void)Close();
335  return -EACCES;
336  }
337  return XrdOssOK;
338 }
#define XrdOssOK
Definition: XrdOss.hh:50
int Mode
bool isTagFile(const char *path)
bool IsReadOnly() const
virtual int isCompressed(char *cxidp=0)
Definition: XrdOss.hh:187

References Close(), XrdOssDF::isCompressed(), XrdOssCsiPages::IsReadOnly(), TagPath::isTagFile(), Mode, Pages(), XrdOssDFHandler::successor_, XrdOssCsiConfig::tagParam_, and XrdOssOK.

+ Here is the call graph for this function:

◆ Pages()

XrdOssCsiPages* XrdOssCsiFile::Pages ( )
inline

Definition at line 140 of file XrdOssCsi.hh.

140  {
141  return pmi_->pages.get();
142  }

Referenced by XrdOssCsiFileAioJob::DoItRead1(), XrdOssCsiFileAioJob::DoItRead2(), XrdOssCsiFileAioJob::DoItWrite1(), Flush(), Fstat(), Fsync(), Ftruncate(), Open(), pgRead(), pgWrite(), Read(), ReadRaw(), ReadV(), VerificationStatus(), Write(), and WriteV().

+ Here is the caller graph for this function:

◆ pgRead() [1/2]

ssize_t XrdOssCsiFile::pgRead ( void *  buffer,
off_t  offset,
size_t  rdlen,
uint32_t *  csvec,
uint64_t  opts 
)
virtual

Reimplemented from XrdOssDFHandler.

Definition at line 475 of file XrdOssCsiFile.cc.

476 {
477  if (!pmi_) return -EBADF;
478 
480  Pages()->LockTrackinglen(rg, offset, offset+rdlen, true);
481 
482  // if we return a short amount of data the caller will have to deal with
483  // joining csvec values from repeated reads: for simplicity try to read as
484  // such as possible up to the request read length
485  ssize_t toread = rdlen;
486  ssize_t bread = 0;
487  uint8_t *const p = (uint8_t*)buffer;
488  do
489  {
490  ssize_t rret = successor_->Read(&p[bread], offset+bread, toread);
491  if (rret<0) return rret;
492  if (rret==0) break;
493  toread -= rret;
494  bread += rret;
495  } while(toread>0);
496  if (rdlen == 0) return bread;
497 
498  ssize_t puret = Pages()->FetchRange(successor_, buffer, offset, bread, csvec, opts, rg);
499  if (puret<0) return puret;
500  return bread;
501 }
struct myOpts opts
int FetchRange(XrdOssDF *, const void *, off_t, size_t, uint32_t *, uint64_t, XrdOssCsiRangeGuard &)
virtual ssize_t Read(off_t offset, size_t size)
Definition: XrdOss.hh:281

References XrdOssCsiPages::FetchRange(), XrdOssCsiPages::LockTrackinglen(), opts, Pages(), XrdOssDF::Read(), and XrdOssDFHandler::successor_.

+ Here is the call graph for this function:

◆ pgRead() [2/2]

int XrdOssCsiFile::pgRead ( XrdSfsAio aioparm,
uint64_t  opts 
)
virtual

Read file pages and checksums using asynchronous I/O.

Parameters
aioparm- Pointer to async I/O object controlling the I/O.
opts- Processing options (see above).
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 81 of file XrdOssCsiFileAio.cc.

82 {
83  if (!pmi_) return -EBADF;
84 
85  XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
86  nio->Init(aioparm, this, true, opts, true);
87  nio->SchedReadJob();
88  return 0;
89 }
static XrdOssCsiFileAio * Alloc(XrdOssCsiFileAioStore *store)
void Init(XrdSfsAio *aiop, XrdOssCsiFile *file, bool isPgOp, uint64_t opts, bool isread)

References XrdOssCsiFileAio::Alloc(), XrdOssCsiFileAio::Init(), opts, and XrdOssCsiFileAio::SchedReadJob().

+ Here is the call graph for this function:

◆ pgWrite() [1/2]

ssize_t XrdOssCsiFile::pgWrite ( void *  buffer,
off_t  offset,
size_t  wrlen,
uint32_t *  csvec,
uint64_t  opts 
)
virtual

Write file pages into a file with corresponding checksums.

Parameters
buffer- pointer to buffer containing the bytes to write.
offset- The offset where the write is to start.
wrlen- The number of bytes to write.
csvec- A vector which contains the corresponding CRC32 checksum for each page. See XrdOucPgrwUtils::csNum() for sizing.
opts- Processing options (see above).
Returns
>= 0 The number of bytes written upon success. or -errno or -osserr upon failure. (see XrdOssError.hh).
< 0 -errno or -osserr upon failure. (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 503 of file XrdOssCsiFile.cc.

504 {
505  if (!pmi_) return -EBADF;
506  if (rdonly_) return -EBADF;
507  uint64_t pgopts = opts;
508 
509  const int prec = XrdOssCsiPages::pgWritePrelockCheck(buffer, offset, wrlen, csvec, opts);
510  if (prec < 0)
511  {
512  return prec;
513  }
514 
516  Pages()->LockTrackinglen(rg, offset, offset+wrlen, false);
517 
518  int puret = Pages()->StoreRange(successor_, buffer, offset, wrlen, csvec, pgopts, rg);
519  if (puret<0) {
520  rg.ReleaseAll();
521  resyncSizes();
522  return (ssize_t)puret;
523  }
524  ssize_t towrite = wrlen;
525  ssize_t bwritten = 0;
526  const uint8_t *p = (uint8_t*)buffer;
527  do
528  {
529  ssize_t wret = successor_->Write(&p[bwritten], offset+bwritten, towrite);
530  if (wret<0)
531  {
532  rg.ReleaseAll();
533  resyncSizes();
534  return wret;
535  }
536  towrite -= wret;
537  bwritten += wret;
538  } while(towrite>0);
539  return bwritten;
540 }
static int pgWritePrelockCheck(const void *, off_t, size_t, const uint32_t *, uint64_t)
int StoreRange(XrdOssDF *, const void *, off_t, size_t, uint32_t *, uint64_t, XrdOssCsiRangeGuard &)
virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
Definition: XrdOss.hh:345

References XrdOssCsiPages::LockTrackinglen(), opts, Pages(), XrdOssCsiPages::pgWritePrelockCheck(), XrdOssCsiRangeGuard::ReleaseAll(), XrdOssCsiPages::StoreRange(), XrdOssDFHandler::successor_, and XrdOssDF::Write().

+ Here is the call graph for this function:

◆ pgWrite() [2/2]

int XrdOssCsiFile::pgWrite ( XrdSfsAio aioparm,
uint64_t  opts 
)
virtual

Write file pages and checksums using asynchronous I/O.

Parameters
aioparm- Pointer to async I/O object controlling the I/O.
opts- Processing options (see above).
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 91 of file XrdOssCsiFileAio.cc.

92 {
93  if (!pmi_) return -EBADF;
94  if (rdonly_) return -EBADF;
95  uint64_t pgopts = opts;
96 
97  const int prec = XrdOssCsiPages::pgWritePrelockCheck(
98  (void *)aioparm->sfsAio.aio_buf,
99  (off_t)aioparm->sfsAio.aio_offset,
100  (size_t)aioparm->sfsAio.aio_nbytes,
101  aioparm->cksVec,
102  opts);
103  if (prec < 0)
104  {
105  return prec;
106  }
107 
108  XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
109  nio->Init(aioparm, this, true, pgopts, false);
110  // pages will be locked when write is scheduled
111  nio->SchedWriteJob();
112  return 0;
113 }
off_t aio_offset
Definition: XrdSfsAio.hh:49
size_t aio_nbytes
Definition: XrdSfsAio.hh:48
void * aio_buf
Definition: XrdSfsAio.hh:47
uint32_t * cksVec
Definition: XrdSfsAio.hh:63
struct aiocb sfsAio
Definition: XrdSfsAio.hh:62

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdOssCsiFileAio::Alloc(), XrdSfsAio::cksVec, XrdOssCsiFileAio::Init(), opts, XrdOssCsiPages::pgWritePrelockCheck(), XrdOssCsiFileAio::SchedWriteJob(), and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

◆ Read() [1/3]

ssize_t XrdOssCsiFile::Read ( off_t  offset,
size_t  size 
)
virtual

Preread file blocks into the file system cache.

Parameters
offset- The offset where the read is to start.
size- The number of bytes to pre-read.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 340 of file XrdOssCsiFile.cc.

341 {
342  return successor_->Read(offset, blen);
343 }

References XrdOssDF::Read(), and XrdOssDFHandler::successor_.

+ Here is the call graph for this function:

◆ Read() [2/3]

ssize_t XrdOssCsiFile::Read ( void *  buffer,
off_t  offset,
size_t  size 
)
virtual

Read file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 345 of file XrdOssCsiFile.cc.

346 {
347  if (!pmi_) return -EBADF;
348 
350  Pages()->LockTrackinglen(rg, offset, offset+blen, true);
351 
352  const ssize_t bread = successor_->Read(buff, offset, blen);
353  if (bread<0 || blen==0) return bread;
354 
355  const ssize_t puret = Pages()->VerifyRange(successor_, buff, offset, bread, rg);
356  if (puret<0) return puret;
357  return bread;
358 }
int VerifyRange(XrdOssDF *, const void *, off_t, size_t, XrdOssCsiRangeGuard &)

References XrdOssCsiPages::LockTrackinglen(), Pages(), XrdOssDF::Read(), XrdOssDFHandler::successor_, and XrdOssCsiPages::VerifyRange().

+ Here is the call graph for this function:

◆ Read() [3/3]

int XrdOssCsiFile::Read ( XrdSfsAio aiop)
virtual

Read file bytes using asynchronous I/O.

Parameters
aiop- Pointer to async I/O object controlling the I/O.
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 59 of file XrdOssCsiFileAio.cc.

60 {
61  if (!pmi_) return -EBADF;
62 
63  XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
64  nio->Init(aiop, this, false, 0, true);
65  nio->SchedReadJob();
66  return 0;
67 }

References XrdOssCsiFileAio::Alloc(), XrdOssCsiFileAio::Init(), and XrdOssCsiFileAio::SchedReadJob().

+ Here is the call graph for this function:

◆ ReadRaw()

ssize_t XrdOssCsiFile::ReadRaw ( void *  buffer,
off_t  offset,
size_t  size 
)
virtual

Read uncompressed file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 360 of file XrdOssCsiFile.cc.

361 {
362  if (!pmi_) return -EBADF;
363 
365  Pages()->LockTrackinglen(rg, offset, offset+blen, true);
366 
367  const ssize_t bread = successor_->ReadRaw(buff, offset, blen);
368  if (bread<0 || blen==0) return bread;
369 
370  const ssize_t puret = Pages()->VerifyRange(successor_, buff, offset, bread, rg);
371  if (puret<0) return puret;
372  return bread;
373 }
virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size)
Definition: XrdOss.hh:319

References XrdOssCsiPages::LockTrackinglen(), Pages(), XrdOssDF::ReadRaw(), XrdOssDFHandler::successor_, and XrdOssCsiPages::VerifyRange().

+ Here is the call graph for this function:

◆ ReadV()

ssize_t XrdOssCsiFile::ReadV ( XrdOucIOVec readV,
int  rdvcnt 
)
virtual

Read file bytes as directed by the read vector.

Parameters
readVpointer to the array of read requests.
rdvcntthe number of elements in readV.
Returns
>=0 The numbe of bytes read.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 375 of file XrdOssCsiFile.cc.

376 {
377  if (!pmi_) return -EBADF;
378  if (n==0) return 0;
379 
381  off_t start = readV[0].offset;
382  off_t end = start + (off_t)readV[0].size;
383  for(int i=1; i<n; i++)
384  {
385  const off_t p1 = readV[i].offset;
386  const off_t p2 = p1 + (off_t)readV[i].size;
387  if (p1<start) start = p1;
388  if (p2>end) end = p2;
389  }
390  Pages()->LockTrackinglen(rg, start, end, true);
391 
392  // standard OSS gives -ESPIPE in case of partial read of an element
393  ssize_t rret = successor_->ReadV(readV, n);
394  if (rret<0) return rret;
395  for (int i=0; i<n; i++)
396  {
397  if (readV[i].size == 0) continue;
398  ssize_t puret = Pages()->VerifyRange(successor_, readV[i].data, readV[i].offset, readV[i].size, rg);
399  if (puret<0) return puret;
400  }
401  return rret;
402 }
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
Definition: XrdOss.cc:236
long long offset
Definition: XrdOucIOVec.hh:42

References XrdOssCsiPages::LockTrackinglen(), XrdOucIOVec::offset, Pages(), XrdOssDF::ReadV(), XrdOssDFHandler::successor_, and XrdOssCsiPages::VerifyRange().

+ Here is the call graph for this function:

◆ VerificationStatus()

int XrdOssCsiFile::VerificationStatus ( )

Definition at line 606 of file XrdOssCsiFile.cc.

607 {
608  if (!pmi_) return 0;
609  return Pages()->VerificationStatus();
610 }

References Pages(), and XrdOssCsiPages::VerificationStatus().

+ Here is the call graph for this function:

◆ Write() [1/2]

ssize_t XrdOssCsiFile::Write ( const void *  buffer,
off_t  offset,
size_t  size 
)
virtual

Write file bytes from a buffer.

Parameters
buffer- pointer to buffer where the bytes reside.
offset- The offset where the write is to start.
size- The number of bytes to write.
Returns
>= 0 The number of bytes that were written.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 404 of file XrdOssCsiFile.cc.

405 {
406  if (!pmi_) return -EBADF;
407  if (rdonly_) return -EBADF;
408 
410  Pages()->LockTrackinglen(rg, offset, offset+blen, false);
411 
412  int puret = Pages()->UpdateRange(successor_, buff, offset, blen, rg);
413  if (puret<0)
414  {
415  rg.ReleaseAll();
416  resyncSizes();
417  return (ssize_t)puret;
418  }
419  ssize_t towrite = blen;
420  ssize_t bwritten = 0;
421  const uint8_t *p = (uint8_t*)buff;
422  while(towrite>0)
423  {
424  ssize_t wret = successor_->Write(&p[bwritten], offset+bwritten, towrite);
425  if (wret<0)
426  {
427  rg.ReleaseAll();
428  resyncSizes();
429  return wret;
430  }
431  towrite -= wret;
432  bwritten += wret;
433  }
434  return bwritten;
435 }
int UpdateRange(XrdOssDF *, const void *, off_t, size_t, XrdOssCsiRangeGuard &)

References XrdOssCsiPages::LockTrackinglen(), Pages(), XrdOssCsiRangeGuard::ReleaseAll(), XrdOssDFHandler::successor_, XrdOssCsiPages::UpdateRange(), and XrdOssDF::Write().

+ Here is the call graph for this function:

◆ Write() [2/2]

int XrdOssCsiFile::Write ( XrdSfsAio aiop)
virtual

Write file bytes using asynchronous I/O.

Parameters
aiop- Pointer to async I/O object controlling the I/O.
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 69 of file XrdOssCsiFileAio.cc.

70 {
71  if (!pmi_) return -EBADF;
72  if (rdonly_) return -EBADF;
73 
74  XrdOssCsiFileAio *nio = XrdOssCsiFileAio::Alloc(&aiostore_);
75  nio->Init(aiop, this, false, 0, false);
76  // pages will be locked when write is scheduled
77  nio->SchedWriteJob();
78  return 0;
79 }

References XrdOssCsiFileAio::Alloc(), XrdOssCsiFileAio::Init(), and XrdOssCsiFileAio::SchedWriteJob().

+ Here is the call graph for this function:

◆ WriteV()

ssize_t XrdOssCsiFile::WriteV ( XrdOucIOVec writeV,
int  wrvcnt 
)
virtual

Write file bytes as directed by the write vector.

Parameters
writeVpointer to the array of write requests.
wrvcntthe number of elements in writeV.
Returns
>=0 The numbe of bytes read.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDFHandler.

Definition at line 437 of file XrdOssCsiFile.cc.

438 {
439  if (!pmi_) return -EBADF;
440  if (rdonly_) return -EBADF;
441  if (n==0) return 0;
442 
444  off_t start = writeV[0].offset;
445  off_t end = start + (off_t)writeV[0].size;
446  for(int i=1; i<n; i++)
447  {
448  const off_t p1 = writeV[i].offset;
449  const off_t p2 = p1 + (off_t)writeV[i].size;
450  if (p1<start) start = p1;
451  if (p2>end) end = p2;
452  }
453  Pages()->LockTrackinglen(rg, start, end, false);
454 
455  for (int i=0; i<n; i++)
456  {
457  int ret = Pages()->UpdateRange(successor_, writeV[i].data, writeV[i].offset, writeV[i].size, rg);
458  if (ret<0)
459  {
460  rg.ReleaseAll();
461  resyncSizes();
462  return ret;
463  }
464  }
465  // standard OSS gives -ESPIPE in case of partial write of an element
466  ssize_t wret = successor_->WriteV(writeV, n);
467  if (wret<0)
468  {
469  rg.ReleaseAll();
470  resyncSizes();
471  }
472  return wret;
473 }
virtual ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt)
Definition: XrdOss.cc:257

References XrdOssCsiPages::LockTrackinglen(), XrdOucIOVec::offset, Pages(), XrdOssCsiRangeGuard::ReleaseAll(), XrdOssDFHandler::successor_, XrdOssCsiPages::UpdateRange(), and XrdOssDF::WriteV().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ XrdOssCsiFileAio

friend class XrdOssCsiFileAio
friend

Definition at line 75 of file XrdOssCsi.hh.

◆ XrdOssCsiFileAioJob

friend class XrdOssCsiFileAioJob
friend

Definition at line 76 of file XrdOssCsi.hh.

Member Data Documentation

◆ pumap_

std::unordered_map< std::string, std::shared_ptr< XrdOssCsiFile::puMapItem_t > > XrdOssCsiFile::pumap_
static

Definition at line 160 of file XrdOssCsi.hh.

Referenced by mapRelease(), mapTake(), and XrdOssCsi::Rename().

◆ pumtx_

XrdSysMutex XrdOssCsiFile::pumtx_
static

Definition at line 159 of file XrdOssCsi.hh.

Referenced by mapRelease(), mapTake(), and XrdOssCsi::Rename().


The documentation for this class was generated from the following files: