From 89ad3f3d6b42ec2354917c4d8680c46d283cc872 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 8 Jun 2017 11:35:12 -0700 Subject: [PATCH] nvme: Abort outstanding commands when qpair is deleted These commands should be treated as aborted by spec, so correctly deliver abort notifications when a qpair is deleted. Change-Id: I8af47a3f42f5695ef8e1a70813662e69102720b2 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/364681 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp --- lib/bdev/bdev.c | 2 +- lib/nvme/nvme_pcie.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index d58f67edf..c355dd0bd 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -640,9 +640,9 @@ spdk_bdev_channel_destroy(void *io_device, void *ctx_buf) _spdk_bdev_abort_io(&mgmt_channel->need_buf_small, ch); _spdk_bdev_abort_io(&mgmt_channel->need_buf_large, ch); - assert(ch->io_outstanding == 0); spdk_put_io_channel(ch->channel); spdk_put_io_channel(ch->mgmt_channel); + assert(ch->io_outstanding == 0); } struct spdk_io_channel * diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 8a1aa25ee..c696f6287 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1461,8 +1461,7 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ goto free; } - /* Delete the I/O submission queue and then the completion queue */ - + /* Delete the I/O submission queue */ status.done = false; rc = nvme_pcie_ctrlr_cmd_delete_io_sq(ctrlr, qpair, nvme_completion_poll_cb, &status); if (rc != 0) { @@ -1475,6 +1474,13 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ return -1; } + /* 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 */ status.done = false; rc = nvme_pcie_ctrlr_cmd_delete_io_cq(ctrlr, qpair, nvme_completion_poll_cb, &status); if (rc != 0) {