From 27d47b9a1032bf13ee794e9e9c1d3e2584e02c0e Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Tue, 17 Apr 2018 05:26:25 +0800 Subject: [PATCH] nvmf: make the qpair disconnnect in the right order. Reason: Initiator sends the qpair deletion in wrong order. The correct order should be all io qpairs deletion and then the admin qpair deletion. However, nvme perf does not follow this since we did not catch ctrlr + c. If we catch ctrlr + c, we need to use the spdk app framework, or other methods. We should support this in another patch. Morever, to prevent the incorrect behavior causing the coredump of target, we need also consider such case in our NVMe-oF target design. And this patch, can solve this issue, it will defer the admin qpair deletion when there are still active io qpairs. Change-Id: Iec9b88c1d6254f36963c92402ebfe8bd99abaea5 Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/407771 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu --- lib/nvmf/ctrlr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 6c41c5073..0aa8193c1 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -281,6 +281,12 @@ ctrlr_delete_qpair(void *ctx) struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr; assert(ctrlr != NULL); + assert(ctrlr->num_qpairs > 0); + /* Defer the admin qpair deletion since there are still io qpairs */ + if ((ctrlr->num_qpairs > 1) && (qpair == ctrlr->admin_qpair)) { + spdk_thread_send_msg(qpair->group->thread, ctrlr_delete_qpair, qpair); + return; + } ctrlr->num_qpairs--; TAILQ_REMOVE(&ctrlr->qpairs, qpair, link);