]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async/rdma: use Chunk::get_size to get chunk size
authorChangcheng Liu <changcheng.liu@aliyun.com>
Thu, 13 Jun 2019 11:04:40 +0000 (19:04 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 23 Aug 2019 02:45:22 +0000 (10:45 +0800)
remove Chunk::over interface and add Chunk::get_size interface
1) It's not clear when reading "over" function name.
2) Some places need know the current chunk block effective content size.
3) "Chunk::over()" could be replaced by "Chunk::get_size() == 0"

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/msg/async/rdma/Infiniband.cc
src/msg/async/rdma/Infiniband.h
src/msg/async/rdma/RDMAConnectedSocketImpl.cc

index ab38fcfb2779bf1d02de55b0d438870bbfda2474..f22034eb0d79d9243c1c795298ae40d3c2b61a53 100644 (file)
@@ -522,6 +522,11 @@ void Infiniband::MemoryManager::Chunk::set_bound(uint32_t b)
   bound = b;
 }
 
+uint32_t Infiniband::MemoryManager::Chunk::get_size() const
+{
+  return bound - offset;
+}
+
 void Infiniband::MemoryManager::Chunk::prepare_read(uint32_t b)
 {
   offset = 0;
@@ -535,7 +540,7 @@ uint32_t Infiniband::MemoryManager::Chunk::get_bound()
 
 uint32_t Infiniband::MemoryManager::Chunk::read(char* buf, uint32_t len)
 {
-  uint32_t left = bound - offset;
+  uint32_t left = get_size();
   if (left >= len) {
     memcpy(buf, buffer+offset, len);
     offset += len;
@@ -567,11 +572,6 @@ bool Infiniband::MemoryManager::Chunk::full()
   return offset == bytes;
 }
 
-bool Infiniband::MemoryManager::Chunk::over()
-{
-  return Infiniband::MemoryManager::Chunk::offset == bound;
-}
-
 void Infiniband::MemoryManager::Chunk::clear()
 {
   offset = 0;
index 008ba187d2a08ab23d5ef2f2246025bf45a40679..81967a4b7bc9a02d6d1d6bbf308354c539be49fa 100644 (file)
@@ -209,12 +209,12 @@ class Infiniband {
       void set_offset(uint32_t o);
       uint32_t get_offset();
       void set_bound(uint32_t b);
+      uint32_t get_size() const;
       void prepare_read(uint32_t b);
       uint32_t get_bound();
       uint32_t read(char* buf, uint32_t len);
       uint32_t write(char* buf, uint32_t len);
       bool full();
-      bool over();
       void clear();
 
      public:
index 6c8550d6ab0877e474f68017ce71157022d71914..13b61654c4e8a2f039af877ce8c62fbc77a14a39 100644 (file)
@@ -346,7 +346,7 @@ ssize_t RDMAConnectedSocketImpl::read_buffers(char* buf, size_t len)
     tmp = (*c)->read(buf+read, len-read);
     read += tmp;
     ldout(cct, 25) << __func__ << " this iter read: " << tmp << " bytes." << " offset: " << (*c)->get_offset() << " ,bound: " << (*c)->get_bound()  << ". Chunk:" << *c  << dendl;
-    if ((*c)->over()) {
+    if ((*c)->get_size() == 0) {
       dispatcher->post_chunk_to_pool(*c);
       update_post_backlog();
       ldout(cct, 25) << __func__ << " one chunk over." << dendl;
@@ -356,7 +356,7 @@ ssize_t RDMAConnectedSocketImpl::read_buffers(char* buf, size_t len)
     }
   }
 
-  if (c != buffers.end() && (*c)->over())
+  if (c != buffers.end() && (*c)->get_size() == 0)
     ++c;
   buffers.erase(buffers.begin(), c);
   ldout(cct, 25) << __func__ << " got " << read  << " bytes, buffers size: " << buffers.size() << dendl;