From a62ce898f3b3f35e762d5d7a6c74cfa7ce091b54 Mon Sep 17 00:00:00 2001 From: Changcheng Liu Date: Mon, 1 Jul 2019 10:41:18 +0800 Subject: [PATCH] msg/async/rdma: make clear to get mem_info address The parameter "block" points to mem_info::chunks space. It's not quite clear about the function of "reinterpret_cast(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 --- src/msg/async/rdma/Infiniband.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index f86f3b5cdfed1..5bc19acebd130 100644 --- a/src/msg/async/rdma/Infiniband.cc +++ b/src/msg/async/rdma/Infiniband.cc @@ -746,7 +746,8 @@ void Infiniband::MemoryManager::PoolAllocator::free(char * const block) mem_info *m; std::lock_guard l{lock}; - m = reinterpret_cast(block) - 1; + Chunk *mem_info_chunk = reinterpret_cast(block); + m = reinterpret_cast(reinterpret_cast(mem_info_chunk) - offsetof(mem_info, chunks)); m->ctx->update_stats(-m->nbufs); ibv_dereg_mr(m->mr); m->ctx->manager->free(m); -- 2.39.5