Skip to content

Commit

Permalink
Merge pull request #13810 from yuyuyu101/wip-rdma-inflight
Browse files Browse the repository at this point in the history
msg/async/rdma: destroy QueuePair if needed

Reviewed-by: Adir lev <adirl@mellanox.com>
  • Loading branch information
yuyuyu101 committed Mar 7, 2017
2 parents a07452d + 9e7aa64 commit d124e6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/msg/async/rdma/RDMAStack.cc
Expand Up @@ -37,6 +37,7 @@ RDMADispatcher::~RDMADispatcher()

assert(qp_conns.empty());
assert(dead_queue_pairs.empty());
assert(num_dead_queue_pair == 0);

tx_cc->ack_events();
rx_cc->ack_events();
Expand Down Expand Up @@ -202,13 +203,14 @@ void RDMADispatcher::polling()
// Additionally, don't delete qp while outstanding_buffers isn't empty,
// because we need to check qp's state before sending
perf_logger->set(l_msgr_rdma_inflight_tx_chunks, inflight);
if (!inflight.load()) {
if (num_dead_queue_pair) {
Mutex::Locker l(lock); // FIXME reuse dead qp because creating one qp costs 1 ms
while (!dead_queue_pairs.empty()) {
ldout(cct, 10) << __func__ << " finally delete qp=" << dead_queue_pairs.back() << dendl;
delete dead_queue_pairs.back();
perf_logger->dec(l_msgr_rdma_active_queue_pair);
dead_queue_pairs.pop_back();
--num_dead_queue_pair;
}
}
if (done)
Expand Down Expand Up @@ -296,6 +298,7 @@ void RDMADispatcher::erase_qpn(uint32_t qpn)
auto it = qp_conns.find(qpn);
if (it == qp_conns.end())
return ;
++num_dead_queue_pair;
dead_queue_pairs.push_back(it->second.first);
qp_conns.erase(it);
}
Expand Down
1 change: 1 addition & 0 deletions src/msg/async/rdma/RDMAStack.h
Expand Up @@ -72,6 +72,7 @@ class RDMADispatcher : public CephContext::ForkWatcher {
Infiniband::CompletionChannel *tx_cc, *rx_cc;
EventCallbackRef async_handler;
bool done = false;
std::atomic<uint64_t> num_dead_queue_pair = {0};
Mutex lock; // protect `qp_conns`, `dead_queue_pairs`
// qp_num -> InfRcConnection
// The main usage of `qp_conns` is looking up connection by qp_num,
Expand Down

0 comments on commit d124e6f

Please sign in to comment.