From b952668186d444daa6b42d58fdbd150d90715475 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Tue, 5 Feb 2019 12:50:41 -0700 Subject: [PATCH] rdma: destroy uninitialized qpairs immediately. Connections in the uninitialized state haven't been added to a poll group yet, so submitting dummy requests to them will be pointless since they will never be polled. We need to reject the connection and destroy the qpair immediately. Change-Id: Id5dd711882e1ae7c13ae32c06da2285186b00a1b Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/443470 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/rdma.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index cd4980ce3..461d39b43 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -2593,6 +2593,13 @@ spdk_nvmf_rdma_poll_group_destroy(struct spdk_nvmf_transport_poll_group *group) free(rgroup); } +static void +spdk_nvmf_rdma_qpair_reject_connection(struct spdk_nvmf_rdma_qpair *rqpair) +{ + spdk_nvmf_rdma_event_reject(rqpair->cm_id, SPDK_NVMF_RDMA_ERROR_NO_RESOURCES); + spdk_nvmf_rdma_qpair_destroy(rqpair); +} + static int spdk_nvmf_rdma_poll_group_add(struct spdk_nvmf_transport_poll_group *group, struct spdk_nvmf_qpair *qpair) @@ -2631,8 +2638,7 @@ spdk_nvmf_rdma_poll_group_add(struct spdk_nvmf_transport_poll_group *group, rc = spdk_nvmf_rdma_event_accept(rqpair->cm_id, rqpair); if (rc) { /* Try to reject, but we probably can't */ - spdk_nvmf_rdma_event_reject(rqpair->cm_id, SPDK_NVMF_RDMA_ERROR_NO_RESOURCES); - spdk_nvmf_rdma_qpair_destroy(rqpair); + spdk_nvmf_rdma_qpair_reject_connection(rqpair); return -1; } @@ -2691,6 +2697,17 @@ spdk_nvmf_rdma_close_qpair(struct spdk_nvmf_qpair *qpair) rqpair->disconnect_flags |= RDMA_QP_DISCONNECTING; + /* This happens only when the qpair is disconnected before + * it is added to the poll group. SInce there is no poll group, + * we will never reap the I/O for this connection. This also + * means that we have not accepted the connection request yet, + * so we need to reject it. + */ + if (rqpair->qpair.state == SPDK_NVMF_QPAIR_UNINITIALIZED) { + spdk_nvmf_rdma_qpair_reject_connection(rqpair); + return; + } + if (rqpair->ibv_attr.qp_state != IBV_QPS_ERR) { spdk_nvmf_rdma_set_ibv_state(rqpair, IBV_QPS_ERR); }