From 5874e2ac6c200eda85842fad1ab00793eafc286f Mon Sep 17 00:00:00 2001 From: JinYu Date: Thu, 28 Mar 2019 03:00:24 +0800 Subject: [PATCH] nvme:complete I/O and abort rest I/O before destroy io_qpair Logically we should complete any I/O in the completion queue and abort the rest of the I/O after we delete the submission queue and completion queue, so that we would not lost any complete I/O. We alse should complete I/O and abort I/O before destroy I/O qpair even though the ctrlr/device has been removed. Change-Id: Ieb28ad7b4a3a7be553f70178b29ca870b5413191 Signed-off-by: JinYu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449316 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/nvme/nvme_pcie.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 15945cb2c0..7d495c69fd 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1692,14 +1692,6 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ return -1; } - if (qpair->no_deletion_notification_needed == 0) { - /* Complete any I/O in the completion queue */ - nvme_pcie_qpair_process_completions(qpair, 0); - - /* Abort the rest of the I/O */ - nvme_pcie_qpair_abort_trackers(qpair, 1); - } - /* Delete the completion queue */ rc = nvme_pcie_ctrlr_cmd_delete_io_cq(ctrlr, qpair, nvme_completion_poll_cb, &status); if (rc != 0) { @@ -1711,6 +1703,14 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ } free: + if (qpair->no_deletion_notification_needed == 0) { + /* Complete any I/O in the completion queue */ + nvme_pcie_qpair_process_completions(qpair, 0); + + /* Abort the rest of the I/O */ + nvme_pcie_qpair_abort_trackers(qpair, 1); + } + nvme_pcie_qpair_destroy(qpair); return 0; }