XRootD
XrdCephOssReadVFile Class Reference

#include <XrdCephOssReadVFile.hh>

+ Inheritance diagram for XrdCephOssReadVFile:
+ Collaboration diagram for XrdCephOssReadVFile:

Public Member Functions

 XrdCephOssReadVFile (XrdCephOss *cephoss, XrdCephOssFile *cephossDF, const std::string &algname)
 
virtual ~XrdCephOssReadVFile ()
 
virtual int Close (long long *retsz=0)
 
virtual int Fstat (struct stat *buff)
 
virtual int Fsync (void)
 
virtual int Ftruncate (unsigned long long)
 
virtual int Open (const char *path, int flags, mode_t mode, XrdOucEnv &env)
 
virtual ssize_t Read (off_t offset, size_t blen)
 
virtual ssize_t Read (void *buff, off_t offset, size_t blen)
 
virtual int Read (XrdSfsAio *aoip)
 
virtual ssize_t ReadRaw (void *, off_t, size_t)
 
virtual ssize_t ReadV (XrdOucIOVec *readV, int rdvcnt)
 
virtual ssize_t Write (const void *buff, off_t offset, size_t blen)
 
virtual int Write (XrdSfsAio *aiop)
 
- Public Member Functions inherited from XrdCephOssFile
 XrdCephOssFile (XrdCephOss *cephoss)
 
virtual ~XrdCephOssFile ()
 
virtual int getFileDescriptor () const
 
- Public Member Functions inherited from XrdOssDF
 XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
 
virtual ~XrdOssDF ()
 
uint16_t DFType ()
 
virtual int Fchmod (mode_t mode)
 
virtual int Fctl (int cmd, int alen, const char *args, char **resp=0)
 
virtual void Flush ()
 Flush filesystem cached pages for this file (used for checksums). More...
 
virtual int Fsync (XrdSfsAio *aiop)
 
virtual int getFD ()
 
virtual off_t getMmap (void **addr)
 
virtual const char * getTID ()
 
virtual int isCompressed (char *cxidp=0)
 
virtual int Opendir (const char *path, XrdOucEnv &env)
 
virtual ssize_t pgRead (void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
 
virtual int pgRead (XrdSfsAio *aioparm, uint64_t opts)
 
virtual ssize_t pgWrite (void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
 
virtual int pgWrite (XrdSfsAio *aioparm, uint64_t opts)
 
virtual int Readdir (char *buff, int blen)
 
virtual int StatRet (struct stat *buff)
 
virtual ssize_t WriteV (XrdOucIOVec *writeV, int wrvcnt)
 

Protected Attributes

std::string m_algname = "passthrough"
 
XrdCephOssm_cephoss = nullptr
 
bool m_extraLogging = true
 
std::unique_ptr< XrdCephBuffer::IXrdCephReadVAdapterm_readVAdapter
 
std::atomic< long > m_timer_count {0}
 timer for the reads against ceph More...
 
std::atomic< long > m_timer_longest {0}
 number of reads More...
 
std::atomic< long > m_timer_read_ns {0}
 
std::atomic< long > m_timer_size {0}
 number of reads More...
 
XrdCephOssFilem_xrdOssDF = nullptr
 
- Protected Attributes inherited from XrdCephOssFile
XrdCephOssm_cephOss
 
int m_fd
 
- Protected Attributes inherited from XrdOssDF
uint16_t dfType
 
int fd
 
off_t pgwEOF
 
short rsvd
 
const char * tident
 

Additional Inherited Members

- 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...
 

Detailed Description

Decorator class XrdCephOssReadVFile designed to wrap XrdCephOssFile Functionality for ReadV access to/from data in Ceph to avoid inefficient small reads / writes from the client side. Initially for monitoring purposes

Definition at line 46 of file XrdCephOssReadVFile.hh.

Constructor & Destructor Documentation

◆ XrdCephOssReadVFile()

XrdCephOssReadVFile::XrdCephOssReadVFile ( XrdCephOss cephoss,
XrdCephOssFile cephossDF,
const std::string &  algname 
)
explicit

Definition at line 49 of file XrdCephOssReadVFile.cc.

49  :
50 XrdCephOssFile(cephoss), m_cephoss(cephoss), m_xrdOssDF(cephossDF),m_algname(algname)
51 {
52  if (!m_xrdOssDF) XrdCephEroute.Say("XrdCephOssReadVFile::Null m_xrdOssDF");
53 
54  if (m_algname == "passthrough") { // #TODO consider to use a factory method. but this is simple enough for now
55  m_readVAdapter = std::unique_ptr<XrdCephBuffer::IXrdCephReadVAdapter>(new XrdCephBuffer::XrdCephReadVNoOp());
56  } else if (m_algname == "basic") {
57  m_readVAdapter = std::unique_ptr<XrdCephBuffer::IXrdCephReadVAdapter>(new XrdCephBuffer::XrdCephReadVBasic());
58  } else {
59  XrdCephEroute.Say("XrdCephOssReadVFile::ERROR Invalid ReadV algorthm passed; defaulting to passthrough");
60  m_algname = "passthrough";
61  m_readVAdapter = std::unique_ptr<XrdCephBuffer::IXrdCephReadVAdapter>(new XrdCephBuffer::XrdCephReadVNoOp());
62  }
63  LOGCEPH("XrdCephOssReadVFile Algorithm type: " << m_algname);
64 }
XrdSysError XrdCephEroute
#define LOGCEPH(x)
Definition: XrdCephPosix.hh:51
Combine requests into single reads accoriding to some basic rules. Read a minimum amount of data (2Mi...
Passthrough implementation. Convertes the ReadV requests to extents and makes the request....
XrdCephOssFile(XrdCephOss *cephoss)
std::unique_ptr< XrdCephBuffer::IXrdCephReadVAdapter > m_readVAdapter
XrdCephOssFile * m_xrdOssDF
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141

References LOGCEPH, m_algname, m_readVAdapter, m_xrdOssDF, XrdSysError::Say(), and XrdCephEroute.

+ Here is the call graph for this function:

◆ ~XrdCephOssReadVFile()

XrdCephOssReadVFile::~XrdCephOssReadVFile ( )
virtual

Definition at line 66 of file XrdCephOssReadVFile.cc.

66  {
67  if (m_xrdOssDF) {
68  delete m_xrdOssDF;
69  m_xrdOssDF = nullptr;
70  }
71 
72 }

References m_xrdOssDF.

Member Function Documentation

◆ Close()

int XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 84 of file XrdCephOssReadVFile.cc.

84  {
85  LOGCEPH("XrdCephOssReadVFile::Close: retsz: " << retsz << " Time_ceph_s: " << m_timer_read_ns.load()*1e-9 << " count: "
86  << m_timer_count.load() << " size_B: " << m_timer_size.load()
87  << " longest_s:" << m_timer_longest.load()*1e-9);
88 
89  return m_xrdOssDF->Close(retsz);
90 }
virtual int Close(long long *retsz=0)
std::atomic< long > m_timer_longest
number of reads
std::atomic< long > m_timer_size
number of reads
std::atomic< long > m_timer_read_ns
std::atomic< long > m_timer_count
timer for the reads against ceph

References XrdCephOssFile::Close(), LOGCEPH, m_timer_count, m_timer_longest, m_timer_read_ns, m_timer_size, and m_xrdOssDF.

+ Here is the call graph for this function:

◆ Fstat()

int XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 197 of file XrdCephOssReadVFile.cc.

197  {
198  return m_xrdOssDF->Fstat(buff);
199 }
virtual int Fstat(struct stat *buff)

References XrdCephOssFile::Fstat(), and m_xrdOssDF.

+ Here is the call graph for this function:

◆ Fsync()

int XrdCephOssReadVFile::Fsync ( void  )
virtual

Synchronize associated file with media (synchronous).

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

Reimplemented from XrdCephOssFile.

Definition at line 209 of file XrdCephOssReadVFile.cc.

209  {
210  return m_xrdOssDF->Fsync();
211 }
virtual int Fsync(void)

References XrdCephOssFile::Fsync(), and m_xrdOssDF.

+ Here is the call graph for this function:

◆ Ftruncate()

int XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 213 of file XrdCephOssReadVFile.cc.

213  {
214  return m_xrdOssDF->Ftruncate(len);
215 }
virtual int Ftruncate(unsigned long long)

References XrdCephOssFile::Ftruncate(), and m_xrdOssDF.

+ Here is the call graph for this function:

◆ Open()

int XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 74 of file XrdCephOssReadVFile.cc.

74  {
75  int rc = m_xrdOssDF->Open(path, flags, mode, env);
76  if (rc < 0) {
77  return rc;
78  }
80  LOGCEPH("XrdCephOssReadVFile::Open: fd: " << m_fd << " " << path );
81  return rc;
82 }
virtual int Open(const char *path, int flags, mode_t mode, XrdOucEnv &env)
virtual int getFileDescriptor() const

References XrdCephOssFile::getFileDescriptor(), LOGCEPH, XrdCephOssFile::m_fd, m_xrdOssDF, and XrdCephOssFile::Open().

+ Here is the call graph for this function:

◆ Read() [1/3]

ssize_t XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 181 of file XrdCephOssReadVFile.cc.

181  {
182  return m_xrdOssDF->Read(offset,blen);
183 }
virtual ssize_t Read(off_t offset, size_t blen)

References m_xrdOssDF, and XrdCephOssFile::Read().

+ Here is the call graph for this function:

◆ Read() [2/3]

ssize_t XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 185 of file XrdCephOssReadVFile.cc.

185  {
186  return m_xrdOssDF->Read(buff,offset,blen);
187 }

References m_xrdOssDF, and XrdCephOssFile::Read().

+ Here is the call graph for this function:

◆ Read() [3/3]

int XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 189 of file XrdCephOssReadVFile.cc.

189  {
190  return m_xrdOssDF->Read(aiop);
191 }

References m_xrdOssDF, and XrdCephOssFile::Read().

+ Here is the call graph for this function:

◆ ReadRaw()

ssize_t XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 193 of file XrdCephOssReadVFile.cc.

193  {
194  return m_xrdOssDF->ReadRaw(buff, offset, blen);
195 }
virtual ssize_t ReadRaw(void *, off_t, size_t)

References m_xrdOssDF, and XrdCephOssFile::ReadRaw().

+ Here is the call graph for this function:

◆ ReadV()

ssize_t XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 93 of file XrdCephOssReadVFile.cc.

93  {
95  LOGCEPH("XrdCephOssReadVFile::ReadV: fd: " << fd << " " << rnum );
96 
97  std::stringstream msg_extents;
98  msg_extents << "XrdCephOssReadVFile::Extentslist={\"fd\": " << fd << ", \"EXTENTS\":[";
99 
100  ExtentHolder extents(rnum);
101  for (int i = 0; i < rnum; i++) {
102  extents.push_back(Extent(readV[i].offset, readV[i].size));
103  msg_extents << "[" << readV[i].offset << "," << readV[i].size << "]," ;
104  }
105  msg_extents << "]}";
106  //XrdCephEroute.Say(msg_extents.str().c_str()); msg_extents.clear();
107  if (m_extraLogging) {
108  // improve this so no wasted calls if logging is disabled
109  LOGCEPH(msg_extents.str());
110  msg_extents.clear();
111  }
112 
113  LOGCEPH("XrdCephOssReadVFile::Extents: fd: "<< fd << " " << extents.size() << " " << extents.len() << " "
114  << extents.begin() << " " << extents.end() << " " << extents.bytesContained()
115  << " " << extents.bytesMissing());
116 
117  // take the input set of extents and return a vector of merged extents (covering the range to read)
118  std::vector<ExtentHolder> mappedExtents = m_readVAdapter->convert(extents);
119 
120 
121  // counter is the iterator to the original readV elements, and is incremented for each chunk that's returned
122  int nbytes = 0, curCount = 0, counter(0);
123  size_t totalBytesRead(0), totalBytesUseful(0);
124 
125  // extract the largest range of the extents, and create a buffer.
126  size_t buffersize{0};
127  for (std::vector<ExtentHolder>::const_iterator ehit = mappedExtents.cbegin(); ehit!= mappedExtents.cend(); ++ehit ) {
128  buffersize = std::max(buffersize, ehit->len());
129  }
130  std::vector<char> buffer;
131  buffer.reserve(buffersize);
132 
133 
134  //LOGCEPH("mappedExtents: len: " << mappedExtents.size() );
135  for (std::vector<ExtentHolder>::const_iterator ehit = mappedExtents.cbegin(); ehit!= mappedExtents.cend(); ++ehit ) {
136  off_t off = ehit->begin();
137  size_t len = ehit->len();
138 
139  //LOGCEPH("outerloop: " << off << " " << len << " " << ehit->end() << " " << " " << ehit->size() );
140 
141  // read the full extent into the buffer
142  long timed_read_ns{0};
143  {Timer_ns ts(timed_read_ns);
144  curCount = m_xrdOssDF->Read(buffer.data(), off, len);
145  } // timer scope
146  ++m_timer_count;
147  auto l = m_timer_longest.load();
148  m_timer_longest.store(std::max(l,timed_read_ns)); // doesn't quite prevent race conditions
149  m_timer_read_ns.fetch_add(timed_read_ns);
150  m_timer_size.fetch_add(curCount);
151 
152  // check that the correct amount of data was read.
153  // std:: clog << "buf Read " << curCount << std::endl;
154  if (curCount != (ssize_t)len) {
155  return (curCount < 0 ? curCount : -ESPIPE);
156  }
157  totalBytesRead += curCount;
158  totalBytesUseful += ehit->bytesContained();
159 
160 
161  // now read out into the original readV requests for each of the held inner extents
162  const char* data = buffer.data();
163  const ExtentContainer& innerExtents = ehit->extents();
164  for (ExtentContainer::const_iterator it = innerExtents.cbegin(); it != innerExtents.cend(); ++it) {
165  off_t innerBegin = it->begin() - off;
166  off_t innerEnd = it->end() - off;
167  //LOGCEPH( "innerloop: " << innerBegin << " " << innerEnd << " " << off << " "
168  // << it->begin() << " " << it-> end() << " "
169  // << readV[counter].offset << " " << readV[counter].size);
170  std::copy(data+innerBegin, data+innerEnd, readV[counter].data );
171  nbytes += it->len();
172  ++counter; // next element
173  } // inner extents
174 
175  } // outer extents
176  LOGCEPH( "readV returning " << nbytes << " bytes: " << "Read: " <<totalBytesRead << " Useful: " << totalBytesUseful );
177  return nbytes;
178 
179 }
static std::string ts()
timestamp output for logging messages
Definition: XrdCephOss.cc:53
Designed to hold individual extents, but itself provide Extent-like capabilities Useful in cases of c...
Definition: BufferUtils.hh:109
int fd
Definition: XrdOss.hh:455
std::vector< Extent > ExtentContainer
Container defintion for Extents Typedef to provide a container of extents as a simple stl vector cont...
Definition: BufferUtils.hh:99
long long offset
Definition: XrdOucIOVec.hh:42

References XrdCephBuffer::ExtentHolder::begin(), XrdCephBuffer::ExtentHolder::bytesContained(), XrdCephBuffer::ExtentHolder::bytesMissing(), XrdCephBuffer::ExtentHolder::end(), XrdOssDF::fd, XrdCephOssFile::getFileDescriptor(), XrdCephBuffer::ExtentHolder::len(), LOGCEPH, m_extraLogging, m_readVAdapter, m_timer_count, m_timer_longest, m_timer_read_ns, m_timer_size, m_xrdOssDF, XrdOucIOVec::offset, XrdCephBuffer::ExtentHolder::push_back(), XrdCephOssFile::Read(), XrdCephBuffer::ExtentHolder::size(), XrdOucIOVec::size, and ts().

+ Here is the call graph for this function:

◆ Write() [1/2]

ssize_t XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 201 of file XrdCephOssReadVFile.cc.

201  {
202  return m_xrdOssDF->Write(buff,offset,blen);
203 }
virtual ssize_t Write(const void *buff, off_t offset, size_t blen)

References m_xrdOssDF, and XrdCephOssFile::Write().

+ Here is the call graph for this function:

◆ Write() [2/2]

int XrdCephOssReadVFile::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 XrdCephOssFile.

Definition at line 205 of file XrdCephOssReadVFile.cc.

205  {
206  return m_xrdOssDF->Write(aiop);
207 }

References m_xrdOssDF, and XrdCephOssFile::Write().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_algname

std::string XrdCephOssReadVFile::m_algname = "passthrough"
protected

Definition at line 80 of file XrdCephOssReadVFile.hh.

Referenced by XrdCephOssReadVFile().

◆ m_cephoss

XrdCephOss* XrdCephOssReadVFile::m_cephoss = nullptr
protected

Definition at line 77 of file XrdCephOssReadVFile.hh.

◆ m_extraLogging

bool XrdCephOssReadVFile::m_extraLogging = true
protected

Definition at line 79 of file XrdCephOssReadVFile.hh.

Referenced by ReadV().

◆ m_readVAdapter

std::unique_ptr<XrdCephBuffer::IXrdCephReadVAdapter> XrdCephOssReadVFile::m_readVAdapter
protected

Definition at line 81 of file XrdCephOssReadVFile.hh.

Referenced by XrdCephOssReadVFile(), and ReadV().

◆ m_timer_count

std::atomic<long> XrdCephOssReadVFile::m_timer_count {0}
protected

timer for the reads against ceph

Definition at line 84 of file XrdCephOssReadVFile.hh.

Referenced by Close(), and ReadV().

◆ m_timer_longest

std::atomic<long> XrdCephOssReadVFile::m_timer_longest {0}
protected

number of reads

Definition at line 86 of file XrdCephOssReadVFile.hh.

Referenced by Close(), and ReadV().

◆ m_timer_read_ns

std::atomic<long> XrdCephOssReadVFile::m_timer_read_ns {0}
protected

Definition at line 83 of file XrdCephOssReadVFile.hh.

Referenced by Close(), and ReadV().

◆ m_timer_size

std::atomic<long> XrdCephOssReadVFile::m_timer_size {0}
protected

number of reads

Definition at line 85 of file XrdCephOssReadVFile.hh.

Referenced by Close(), and ReadV().

◆ m_xrdOssDF

XrdCephOssFile* XrdCephOssReadVFile::m_xrdOssDF = nullptr
protected

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