]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/rdma: make clear to get mem_info address
authorChangcheng Liu <changcheng.liu@aliyun.com>
Mon, 1 Jul 2019 02:41:18 +0000 (10:41 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 23 Aug 2019 03:35:55 +0000 (11:35 +0800)
The parameter "block" points to mem_info::chunks space. It's not quite
clear about the function of "reinterpret_cast<mem_info *>(block) - 1;".
Get the mem_info::chunks address and minus the member offset from struct
head to get mem_info address.

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

index f86f3b5cdfed11fb3e99ffba5beed5def506c7cf..5bc19acebd1303e0ed55f49453f28c119fac5115 100644 (file)
@@ -746,7 +746,8 @@ void Infiniband::MemoryManager::PoolAllocator::free(char * const block)
   mem_info *m;
   std::lock_guard l{lock};
     
-  m = reinterpret_cast<mem_info *>(block) - 1;
+  Chunk *mem_info_chunk = reinterpret_cast<Chunk *>(block);
+  m = reinterpret_cast<mem_info *>(reinterpret_cast<char *>(mem_info_chunk) - offsetof(mem_info, chunks));
   m->ctx->update_stats(-m->nbufs);
   ibv_dereg_mr(m->mr);
   m->ctx->manager->free(m);