* Return true if the queue pair is in an error state, false otherwise.
*/
bool is_error() const;
- /**
- * Add Tx work request and completion counters.
- */
void add_tx_wr(uint32_t amt) { tx_wr += amt; }
void add_tx_wc(uint32_t amt) { tx_wc += amt; }
- /**
- * Get Tx work request and completion counter values.
- */
uint32_t get_tx_wr() const { return tx_wr; }
uint32_t get_tx_wc() const { return tx_wc; }
ibv_qp* get_qp() const { return qp; }
uint32_t max_recv_wr;
uint32_t q_key;
bool dead;
- std::atomic<uint32_t> tx_wr; // atomic counter for successful Tx WQEs
- std::atomic<uint32_t> tx_wc; // atomic counter for successful Tx CQEs
+ std::atomic<uint32_t> tx_wr = {0}; // counter for successful Tx WQEs
+ std::atomic<uint32_t> tx_wc = {0}; // counter for successful Tx CQEs
};
public:
worker->perf_logger->inc(l_msgr_rdma_tx_failed);
return -errno;
}
- // Update the Tx WQE counter
qp->add_tx_wr(num);
worker->perf_logger->inc(l_msgr_rdma_tx_chunks, tx_buffers.size());
ldout(cct, 20) << __func__ << " qp state is " << Infiniband::qp_state_string(qp->get_state()) << dendl;
worker->perf_logger->inc(l_msgr_rdma_tx_failed);
return ;
}
- // Update the Tx WQE counter
qp->add_tx_wr(1);
}
perf_logger->set(l_msgr_rdma_inflight_tx_chunks, inflight);
if (num_dead_queue_pair) {
Mutex::Locker l(lock); // FIXME reuse dead qp because creating one qp costs 1 ms
- for (auto idx = 0; idx < dead_queue_pairs.size(); idx++) {
+ for (auto &i : dead_queue_pairs) {
// Bypass QPs that do not collect all Tx completions yet.
- if (dead_queue_pairs.at(idx)->get_tx_wc() != dead_queue_pairs.at(idx)->get_tx_wr())
+ if (i->get_tx_wc() != i->get_tx_wr())
continue;
- ldout(cct, 10) << __func__ << " finally delete qp=" << dead_queue_pairs.at(idx) << dendl;
- delete dead_queue_pairs.at(idx);
- dead_queue_pairs.erase(dead_queue_pairs.begin() + idx);
+ ldout(cct, 10) << __func__ << " finally delete qp=" << i << dendl;
+ delete i;
+ auto it = std::find(dead_queue_pairs.begin(), dead_queue_pairs.end(), i);
+ if (it != dead_queue_pairs.end())
+ dead_queue_pairs.erase(it);
perf_logger->dec(l_msgr_rdma_active_queue_pair);
--num_dead_queue_pair;
}
Mutex::Locker l(lock);
// Try to find the QP in qp_conns firstly.
auto it = qp_conns.find(qp);
- if (it == qp_conns.end()) {
- // Try again in dead_queue_pairs.
- for(auto dead_qp = dead_queue_pairs.begin(); dead_qp != dead_queue_pairs.end(); dead_qp++) {
- if ((*dead_qp)->get_local_qp_number() == qp)
- return *dead_qp;
- }
- return nullptr;
- }
- return it->second.first;
+ if (it != qp_conns.end())
+ return it->second.first;
+
+ // Try again in dead_queue_pairs.
+ for (auto &i: dead_queue_pairs)
+ if (i->get_local_qp_number() == qp)
+ return i;
+
+ return nullptr;
}
void RDMADispatcher::erase_qpn_lockless(uint32_t qpn)