From 6f38799b6ebc69c333886eb05c7e05b03ab58bd7 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Wed, 15 Apr 2020 21:58:45 -0700 Subject: [PATCH] lib/nvmf: call ctrlr_fini after clearing qid from ctrlr bit array. As soon as we disconnect the qpair, the initiator can submit an additional request to connect a qpair with the same qid as the one we connected. This series is aimed at making sure we don't acknowledge a disconnect until we have cleared that bit. Signed-off-by: Seth Howell Change-Id: I76d9312448a9740911465c146a195996cc567370 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1880 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk --- lib/nvmf/nvmf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index c3cc39264..2f762e27a 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -778,6 +778,14 @@ void _nvmf_ctrlr_destruct(void *ctx) spdk_nvmf_ctrlr_destruct(ctrlr); } +static void +_nvmf_transport_qpair_fini(void *ctx) +{ + struct spdk_nvmf_qpair *qpair = ctx; + + spdk_nvmf_transport_qpair_fini(qpair); +} + static void _spdk_nvmf_ctrlr_free_from_qpair(void *ctx) { @@ -793,6 +801,7 @@ _spdk_nvmf_ctrlr_free_from_qpair(void *ctx) spdk_thread_send_msg(ctrlr->subsys->thread, _nvmf_ctrlr_destruct, ctrlr); } + spdk_thread_send_msg(qpair_ctx->thread, _nvmf_transport_qpair_fini, qpair_ctx->qpair); if (qpair_ctx->cb_fn) { spdk_thread_send_msg(qpair_ctx->thread, qpair_ctx->cb_fn, qpair_ctx->ctx); } @@ -840,9 +849,8 @@ _spdk_nvmf_qpair_destroy(void *ctx, int status) TAILQ_REMOVE(&qpair->group->qpairs, qpair, link); - spdk_nvmf_transport_qpair_fini(qpair); - if (!ctrlr || !ctrlr->thread) { + spdk_nvmf_transport_qpair_fini(qpair); if (qpair_ctx->cb_fn) { spdk_thread_send_msg(qpair_ctx->thread, qpair_ctx->cb_fn, qpair_ctx->ctx); }