From 97277e145982f6d3ab1df2effc8822ca8db916ad Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 30 Nov 2021 17:36:26 +0800 Subject: [PATCH] nvme: use transport internal queue state when deleting unfinished IO queue pair The NVMe bdev module enables asynchronous IO QP creation by default, after calling `spdk_nvme_ctrlr_alloc_io_qpair` and `spdk_nvme_ctrlr_connect_io_qpair`, the queue pair is in connecting state at the beginning, then users may call `spdk_nvme_ctrlr_free_io_qpair` immediately, and the common layer will change queue state to NVME_QPAIR_DISCONNECTING and NVME_QPAIR_DESTROYING, so in function `nvme_pcie_ctrlr_delete_io_qpair` the workaround to wait for create cq/sq callbacks will not be called, instead of using the common layer queue state here, we should use the internal `pcie_state`. Fix #2245. Change-Id: I801caf26563464b135035bf7fa2f63def13de9f4 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10445 Reviewed-by: Dong Yi Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris Reviewed-by: Monica Kenguva Tested-by: SPDK CI Jenkins --- lib/nvme/nvme_pcie_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nvme/nvme_pcie_common.c b/lib/nvme/nvme_pcie_common.c index 4b73c4252..8bca0503e 100644 --- a/lib/nvme/nvme_pcie_common.c +++ b/lib/nvme/nvme_pcie_common.c @@ -1097,7 +1097,8 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ /* If attempting to delete a qpair that's still being connected, we have to wait until it's * finished, so that we don't free it while it's waiting for the create cq/sq callbacks. */ - while (nvme_qpair_get_state(qpair) == NVME_QPAIR_CONNECTING) { + while (pqpair->pcie_state == NVME_PCIE_QPAIR_WAIT_FOR_CQ || + pqpair->pcie_state == NVME_PCIE_QPAIR_WAIT_FOR_SQ) { rc = spdk_nvme_qpair_process_completions(ctrlr->adminq, 0); if (rc < 0) { break;