XRootD
XrdCephBuffer::CephIOAdapterRaw Class Reference

Implements a non-async read and write to ceph via ceph_posix calls Using the standard ceph_posix_ calls do the actual read and write operations. No ownership is taken on the buffer that's passed via the constructor. More...

#include <CephIOAdapterRaw.hh>

+ Inheritance diagram for XrdCephBuffer::CephIOAdapterRaw:
+ Collaboration diagram for XrdCephBuffer::CephIOAdapterRaw:

Public Member Functions

 CephIOAdapterRaw (IXrdCephBufferData *bufferdata, int fd, bool useStriperlessReads)
 
virtual ~CephIOAdapterRaw ()
 
virtual ssize_t read (off64_t offset, size_t count) override
 Issue a ceph_posix_pread to read to the buffer data from file offset and len count. No range checking is currently provided here. The caller must provide sufficient space for the max len read. Returns -ve errorcode on failure, else the number of bytes returned. More...
 
virtual ssize_t write (off64_t offset, size_t count) override
 Take the data in the buffer and write to ceph at given offset Issues a ceph_posix_pwrite for data in the buffer (from pos 0) into ceph at position offset with len count. Returns -ve on error, else the number of bytes writen. More...
 
- Public Member Functions inherited from XrdCephBuffer::ICephIOAdapter
virtual ~ICephIOAdapter ()
 

Detailed Description

Implements a non-async read and write to ceph via ceph_posix calls Using the standard ceph_posix_ calls do the actual read and write operations. No ownership is taken on the buffer that's passed via the constructor.

Definition at line 28 of file CephIOAdapterRaw.hh.

Constructor & Destructor Documentation

◆ CephIOAdapterRaw()

CephIOAdapterRaw::CephIOAdapterRaw ( IXrdCephBufferData bufferdata,
int  fd,
bool  useStriperlessReads 
)

Definition at line 14 of file CephIOAdapterRaw.cc.

15  :
16  m_bufferdata(bufferdata),m_fd(fd),
17  m_useStriperlessReads(useStriperlessReads) {
18 }

◆ ~CephIOAdapterRaw()

CephIOAdapterRaw::~CephIOAdapterRaw ( )
virtual

Definition at line 20 of file CephIOAdapterRaw.cc.

20  {
21  // nothing to specifically to do; just print out some stats
22  float read_speed{0}, write_speed{0};
23  if (m_stats_read_req.load() > 0 && m_stats_read_timer.load() > 0 ) {
24  read_speed = m_stats_read_bytes.load() / m_stats_read_timer.load() * 1e-6;
25  }
26  if (m_stats_write_req.load() > 0 && m_stats_read_timer.load() > 0 ) {
27  write_speed = m_stats_write_bytes.load() / m_stats_write_timer.load() * 1e-6;
28  }
29  BUFLOG("CephIOAdapterRaw::Summary fd:" << m_fd
30  << " nwrite:" << m_stats_write_req << " byteswritten:" << m_stats_write_bytes << " write_s:"
31  << m_stats_write_timer * 1e-6 << " writemax_s" << m_stats_write_longest * 1e-6
32  << " write_MBs:" << write_speed
33  << " nread:" << m_stats_read_req << " bytesread:" << m_stats_read_bytes << " read_s:"
34  << m_stats_read_timer * 1e-6 << " readmax_s:" << m_stats_read_longest * 1e-6
35  << " read_MBs:" << read_speed
36  << " striperlessRead: " << m_useStriperlessReads
37  );
38 
39 }
#define BUFLOG(x)
Definition: BufferUtils.hh:23

References BUFLOG.

Member Function Documentation

◆ read()

ssize_t CephIOAdapterRaw::read ( off64_t  offset,
size_t  count 
)
overridevirtual

Issue a ceph_posix_pread to read to the buffer data from file offset and len count. No range checking is currently provided here. The caller must provide sufficient space for the max len read. Returns -ve errorcode on failure, else the number of bytes returned.

Parameters
offset
count
Returns
ssize_t

Implements XrdCephBuffer::ICephIOAdapter.

Definition at line 62 of file CephIOAdapterRaw.cc.

62  {
63  void* buf = m_bufferdata->raw();
64  if (!buf) {
65  return -EINVAL;
66  }
67  ssize_t rc {0};
68 
69  // no check is made whether the buffer has sufficient capacity
70  auto start = std::chrono::steady_clock::now();
71  rc = ceph_posix_maybestriper_pread(m_fd,buf,count,offset, m_useStriperlessReads);
72  auto end = std::chrono::steady_clock::now();
73  //auto elapsed = end-start;
74  auto int_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(end-start);
75 
76  if (rc < 0) {
77  BUFLOG("CephIOAdapterRaw::read: Error in read: " << rc );
78  return rc;
79  }
80 
81  m_stats_read_longest = std::max(m_stats_read_longest,static_cast<long long>(int_ns.count()));
82  m_stats_read_timer.fetch_add(static_cast<long long>(int_ns.count()));
83  m_stats_read_bytes.fetch_add(rc);
84  ++m_stats_read_req;
85 
86  // BUFLOG("CephIOAdapterRaw::read fd:" << m_fd << " " << rc << " " << offset
87  // << " " << count << " " << rc << " " << int_ms.count() );
88 
89  if (rc>=0) {
90  m_bufferdata->setLength(rc);
91  m_bufferdata->setStartingOffset(offset);
92  m_bufferdata->setValid(true);
93  }
94  return rc;
95 }
ssize_t ceph_posix_maybestriper_pread(int fd, void *buf, size_t count, off64_t offset, bool allowStriper)
virtual off_t setStartingOffset(off_t offset)=0
virtual void setLength(size_t len)=0
Currently occupied and valid space, which may be less than capacity.
virtual void setValid(bool isValid)=0
virtual const void * raw() const =0
write data into the buffer, store the external offset

References BUFLOG, ceph_posix_maybestriper_pread(), XrdCephBuffer::IXrdCephBufferData::raw(), XrdCephBuffer::IXrdCephBufferData::setLength(), XrdCephBuffer::IXrdCephBufferData::setStartingOffset(), and XrdCephBuffer::IXrdCephBufferData::setValid().

+ Here is the call graph for this function:

◆ write()

ssize_t CephIOAdapterRaw::write ( off64_t  offset,
size_t  count 
)
overridevirtual

Take the data in the buffer and write to ceph at given offset Issues a ceph_posix_pwrite for data in the buffer (from pos 0) into ceph at position offset with len count. Returns -ve on error, else the number of bytes writen.

Parameters
offset
count
Returns
ssize_t

Implements XrdCephBuffer::ICephIOAdapter.

Definition at line 41 of file CephIOAdapterRaw.cc.

41  {
42  const void* buf = m_bufferdata->raw();
43  if (!buf) return -EINVAL;
44 
45  auto start = std::chrono::steady_clock::now();
46  ssize_t rc = ceph_posix_pwrite(m_fd,buf,count,offset);
47  auto end = std::chrono::steady_clock::now();
48  auto int_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(end-start);
49 
50  // BUFLOG("CephIOAdapterRaw::write fd:" << m_fd << " " << rc << " "
51  // << offset << " " << count << " " << rc << " " << int_ms.count() );
52 
53  if (rc < 0) return rc;
54  m_stats_write_longest = std::max(m_stats_write_longest,static_cast<long long>(int_ns.count()));
55  m_stats_write_timer.fetch_add(static_cast<long long>(int_ns.count()));
56  m_stats_write_bytes.fetch_add(rc);
57  ++m_stats_write_req;
58  return rc;
59 }
ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset)

References ceph_posix_pwrite(), and XrdCephBuffer::IXrdCephBufferData::raw().

+ Here is the call graph for this function:

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