diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index e1513585d..db1565c4a 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -142,7 +142,7 @@ _spdk_nvmf_subsystem_add_ctrlr(void *ctx) return; } - spdk_thread_send_msg(qpair->group->thread, _spdk_nvmf_ctrlr_add_admin_qpair, req); + spdk_thread_send_msg(ctrlr->thread, _spdk_nvmf_ctrlr_add_admin_qpair, req); } static struct spdk_nvmf_ctrlr * @@ -164,6 +164,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem, req->qpair->ctrlr = ctrlr; ctrlr->subsys = subsystem; + ctrlr->thread = req->qpair->group->thread; ctrlr->qpair_mask = spdk_bit_array_create(tgt->opts.max_qpairs_per_ctrlr); if (!ctrlr->qpair_mask) { diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 346d3fed9..de039ef4b 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -653,7 +653,6 @@ _spdk_nvmf_ctrlr_free_from_qpair(void *ctx) spdk_bit_array_clear(ctrlr->qpair_mask, qpair_ctx->qid); count = spdk_bit_array_count_set(ctrlr->qpair_mask); if (count == 0) { - /* TODO: Verify that qpair mask has been cleared. */ spdk_bit_array_free(&ctrlr->qpair_mask); spdk_thread_send_msg(ctrlr->subsys->thread, _nvmf_ctrlr_destruct, ctrlr); @@ -671,12 +670,6 @@ _spdk_nvmf_qpair_destroy(void *ctx, int status) struct nvmf_qpair_disconnect_ctx *qpair_ctx = ctx; struct spdk_nvmf_qpair *qpair = qpair_ctx->qpair; struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr; - struct spdk_thread *thread = NULL; - - if (ctrlr && ctrlr->admin_qpair && ctrlr->admin_qpair->group) { - /* store the thread of admin_qpair and use it later */ - thread = ctrlr->admin_qpair->group->thread; - } TAILQ_REMOVE(&qpair->group->qpairs, qpair, link); qpair->group = NULL; @@ -687,7 +680,7 @@ _spdk_nvmf_qpair_destroy(void *ctx, int status) spdk_nvmf_transport_qpair_fini(qpair); - if (!thread) { + if (!ctrlr || !ctrlr->thread) { if (qpair_ctx->cb_fn) { spdk_thread_send_msg(qpair_ctx->thread, qpair_ctx->cb_fn, qpair_ctx->ctx); } @@ -696,7 +689,7 @@ _spdk_nvmf_qpair_destroy(void *ctx, int status) } qpair_ctx->ctrlr = ctrlr; - spdk_thread_send_msg(thread, _spdk_nvmf_ctrlr_free_from_qpair, qpair_ctx); + spdk_thread_send_msg(ctrlr->thread, _spdk_nvmf_ctrlr_free_from_qpair, qpair_ctx); } diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index d19d5aa64..14809fe95 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -209,8 +209,8 @@ struct spdk_nvmf_ctrlr { struct spdk_nvmf_ctrlr_feat feat; - struct spdk_nvmf_qpair *admin_qpair; - + struct spdk_nvmf_qpair *admin_qpair; + struct spdk_thread *thread; struct spdk_bit_array *qpair_mask; struct spdk_nvmf_request *aer_req;