]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/rdma: refine Chunk construction function
authorChangcheng Liu <changcheng.liu@aliyun.com>
Thu, 27 Jun 2019 03:03:44 +0000 (11:03 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 23 Aug 2019 02:46:16 +0000 (10:46 +0800)
1. all values are initialized in construction function
   In this way, it's easy to construct Chunk object in
   PoolAllocator::malloc function.
2. For read chunk, member bound is initialized to be 0.
3. For send chunk, member bound is initialzied to be full space size.

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

index 3bb207d971acf0f298f06b9dff8968eb24d2d3ef..3702e7b576d1e7d0927a735290a485d51bf56409 100644 (file)
@@ -498,8 +498,9 @@ Infiniband::ProtectionDomain::~ProtectionDomain()
 }
 
 
-Infiniband::MemoryManager::Chunk::Chunk(ibv_mr* m, uint32_t len, char* b)
-  : mr(m), bytes(len), offset(0), buffer(b)
+Infiniband::MemoryManager::Chunk::Chunk(ibv_mr* m, uint32_t bytes, char* buffer,
+    uint32_t offset, uint32_t bound, uint32_t lkey)
+  : mr(m), lkey(lkey), bytes(bytes), offset(offset), bound(bound), buffer(buffer)
 {
 }
 
@@ -600,7 +601,7 @@ int Infiniband::MemoryManager::Cluster::fill(uint32_t num)
   ceph_assert(m);
   Chunk* chunk = chunk_base;
   for (uint32_t offset = 0; offset < bytes; offset += buffer_size){
-    new(chunk) Chunk(m, buffer_size, base+offset);
+    new(chunk) Chunk(m, buffer_size, base + offset, 0, buffer_size, m->lkey);
     free_chunks.push_back(chunk);
     chunk++;
   }
@@ -726,10 +727,7 @@ char *Infiniband::MemoryManager::PoolAllocator::malloc(const size_type bytes)
   /* initialize chunks */
   ch = m->chunks;
   for (unsigned i = 0; i < nbufs; i++) {
-    ch->lkey   = m->mr->lkey;
-    ch->bytes  = cct->_conf->ms_async_rdma_buffer_size;
-    ch->offset = 0;
-    ch->buffer = ch->data; // TODO: refactor tx and remove buffer
+    new(ch) Chunk(m->mr, cct->_conf->ms_async_rdma_buffer_size, ch->data, 0, 0, m->mr->lkey);
     ch = reinterpret_cast<Chunk *>(reinterpret_cast<char *>(ch) + rx_buf_size);
   }
 
index 81967a4b7bc9a02d6d1d6bbf308354c539be49fa..2ddaecf8b3fb60fa170ac829e91c1cc58544cd56 100644 (file)
@@ -203,7 +203,7 @@ class Infiniband {
    public:
     class Chunk {
      public:
-      Chunk(ibv_mr* m, uint32_t len, char* b);
+      Chunk(ibv_mr* m, uint32_t bytes, char* buffer, uint32_t offset = 0, uint32_t bound = 0, uint32_t lkey = 0);
       ~Chunk();
 
       void set_offset(uint32_t o);
@@ -219,10 +219,10 @@ class Infiniband {
 
      public:
       ibv_mr* mr;
-      uint32_t lkey = 0;
+      uint32_t lkey;
       uint32_t bytes;
-      uint32_t bound = 0;
       uint32_t offset;
+      uint32_t bound;
       char* buffer; // TODO: remove buffer/refactor TX
       char  data[0];
     };