From 4aa0bb676b05569b9ed54e631dd266e3dfc9dedc Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 20 Aug 2020 12:34:55 -0700 Subject: [PATCH] nvme/pci: Check for command completions after deleting submission queue After a submission queue is deleted, the device is supposed to post completions for every command to the completion queue. Previously, we never looked and completed all commands with an ABORTED status. Instead, complete any commands in the completion queue with the status the drive gave them. Change-Id: If851a365d4f305cf4390454b6b26dd0f7c5b82ac Signed-off-by: Ben Walker Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3875 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/nvme/nvme_pcie.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 846dd6cad..ef00f804a 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1760,6 +1760,9 @@ nvme_pcie_ctrlr_disconnect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme { } +static int32_t nvme_pcie_qpair_process_completions(struct spdk_nvme_qpair *qpair, + uint32_t max_completions); + static int nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair) { @@ -1792,6 +1795,11 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ return -1; } + /* Now that the submission queue is deleted, the device is supposed to have + * completed any outstanding I/O. Try to complete them. If they don't complete, + * they'll be marked as aborted and completed below. */ + nvme_pcie_qpair_process_completions(qpair, 0); + memset(status, 0, sizeof(*status)); /* Delete the completion queue */ rc = nvme_pcie_ctrlr_cmd_delete_io_cq(ctrlr, qpair, nvme_completion_poll_cb, status);