1. It's wrong to use "-1" as argument to query queue state.
In rdma library, ibv_query_qp will call ibv_cmd_query_qp to query
queue state. If "-1" is used as attr_mask, ibv_cmd_query_qp will
return error EOPNOTSUPP which means query failed.
2. In class QueuePair, is_error() could use member function get_state()
to get the queue pair state.
3. It's better to use qp_state as queue pair state according to
ibv_query_qp manual guide.
struct ibv_qp_attr {
enum ibv_qp_state qp_state; /* Current QP state */
enum ibv_qp_state cur_qp_state; /* Current QP state - irrelevant for ibv_query_qp */
...
Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
bool Infiniband::QueuePair::is_error() const
{
ibv_qp_attr qpa;
- ibv_qp_init_attr qpia;
- int r = ibv_query_qp(qp, &qpa, -1, &qpia);
+ int r = get_state();
if (r) {
lderr(cct) << __func__ << " failed to get state: "
<< cpp_strerror(errno) << dendl;
return true;
}
- return qpa.cur_qp_state == IBV_QPS_ERR;
+ return qpa.qp_state == IBV_QPS_ERR;
}