From b3ddd46e0de0f909cd2dec8aa67d92fde9dc3e6d Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Fri, 24 Sep 2021 18:20:15 +0800 Subject: [PATCH] nvmf/vfio-user: return error when deleting SQ more than once Previously we only use an assertion to address this sceanrio. Fix issue #2173. Change-Id: I7a6e715977218d2a3a08c48a9935880f3fe4ec63 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9604 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Andreas Economides Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- lib/nvmf/vfio_user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 63468e5da8..676f488e2a 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -1290,12 +1290,19 @@ handle_del_io_q(struct nvmf_vfio_user_ctrlr *ctrlr, spdk_nvmf_qpair_disconnect(&vu_qpair->qpair, vfio_user_qpair_delete_cb, ctx); return 0; } else { + if (vu_qpair->state == VFIO_USER_QPAIR_DELETED) { + SPDK_DEBUGLOG(nvmf_vfio, "%s: SQ%u is already deleted\n", ctrlr_id(ctrlr), + cmd->cdw10_bits.delete_io_q.qid); + sct = SPDK_NVME_SCT_COMMAND_SPECIFIC; + sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER; + goto out; + } + /* * This doesn't actually delete the SQ, We're merely telling the poll_group_poll * function to skip checking this SQ. The queue pair will be disconnected in Delete * IO CQ command. */ - assert(vu_qpair->state == VFIO_USER_QPAIR_ACTIVE); vu_qpair->state = VFIO_USER_QPAIR_DELETED; }