nvmf: Store thread in controller structure

The admin queue pair may get disconnected before
the controller is entirely destroyed and can't
be relied on to obtain the correct thread.

Change-Id: I5e80ef286693d53a161134610dd8354c458f8390
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/422134
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: qun wan <qun.wan@intel.com>
This commit is contained in:
Ben Walker 2018-08-13 10:26:26 -07:00 committed by Jim Harris
parent e03aca3ce3
commit 008ec0bd91
3 changed files with 6 additions and 12 deletions

View File

@ -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) {

View File

@ -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);
}

View File

@ -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;