nvme: Explicitly disconnect qpair before destroy

spdk_nvme_ctrlr_free_io_qpair can be called when
qpair is already disconnected. In that case qpair's
state is changed to NVME_QPAIR_DESTROYING and
transport's ctrlr_delete_io_qpair callback is
called. RDMA and TCP transports call
nvme_transport_ctrlr_disconnect_qpair in
the callback and since qpair's state is
not DISCONNECTED or DISCONNECTING, qpair
is disconnected for the second time.

If spdk_nvme_ctrlr_free_io_qpair is called
when qpair is in ENABLED state than nothing
changes, qpair will be disconnected before destroy.
PCIE/vfio_user don't implement transport disconnect
callback, so they are not affected.

Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Change-Id: I23e11856ecafb51669acf4a3118be049c11eecda
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10326
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Alexey Marchuk 2021-11-19 18:23:56 +03:00 committed by Tomasz Zawadzki
parent 4d9b0e3c13
commit 2db77dc9c7
3 changed files with 3 additions and 2 deletions

View File

@ -611,6 +611,8 @@ spdk_nvme_ctrlr_free_io_qpair(struct spdk_nvme_qpair *qpair)
spdk_nvme_poll_group_remove(qpair->poll_group->group, qpair); spdk_nvme_poll_group_remove(qpair->poll_group->group, qpair);
} }
nvme_transport_ctrlr_disconnect_qpair(ctrlr, qpair);
/* Do not retry. */ /* Do not retry. */
nvme_qpair_set_state(qpair, NVME_QPAIR_DESTROYING); nvme_qpair_set_state(qpair, NVME_QPAIR_DESTROYING);

View File

@ -1853,7 +1853,7 @@ nvme_rdma_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_
assert(qpair != NULL); assert(qpair != NULL);
rqpair = nvme_rdma_qpair(qpair); rqpair = nvme_rdma_qpair(qpair);
nvme_transport_ctrlr_disconnect_qpair(ctrlr, qpair);
if (rqpair->defer_deletion_to_pg) { if (rqpair->defer_deletion_to_pg) {
nvme_qpair_set_state(qpair, NVME_QPAIR_DESTROYING); nvme_qpair_set_state(qpair, NVME_QPAIR_DESTROYING);
return 0; return 0;

View File

@ -350,7 +350,6 @@ nvme_tcp_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_q
struct nvme_tcp_qpair *tqpair; struct nvme_tcp_qpair *tqpair;
assert(qpair != NULL); assert(qpair != NULL);
nvme_transport_ctrlr_disconnect_qpair(ctrlr, qpair);
nvme_tcp_qpair_abort_reqs(qpair, 1); nvme_tcp_qpair_abort_reqs(qpair, 1);
nvme_qpair_deinit(qpair); nvme_qpair_deinit(qpair);
tqpair = nvme_tcp_qpair(qpair); tqpair = nvme_tcp_qpair(qpair);