From eb79ef5727ffd89ad722745517889f5dc429692f Mon Sep 17 00:00:00 2001 From: Jacek Kalwas Date: Thu, 4 Jun 2020 16:13:06 +0200 Subject: [PATCH] nvmf: expose api to remove qpair from internal poll group Signed-off-by: Jacek Kalwas Change-Id: I681327d405f60757c43b66592d9af7bd7ac2db0b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2774 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- include/spdk/nvmf_transport.h | 7 +++++++ lib/nvmf/nvmf.c | 22 +++++++++++++++------- lib/nvmf/spdk_nvmf.map | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/spdk/nvmf_transport.h b/include/spdk/nvmf_transport.h index 0f44b1952..e98a5ce24 100644 --- a/include/spdk/nvmf_transport.h +++ b/include/spdk/nvmf_transport.h @@ -400,6 +400,13 @@ void spdk_nvmf_request_exec_fabrics(struct spdk_nvmf_request *req); int spdk_nvmf_request_free(struct spdk_nvmf_request *req); int spdk_nvmf_request_complete(struct spdk_nvmf_request *req); +/** + * Remove the given qpair from the poll group. + * + * \param qpair The qpair to remove. + */ +void spdk_nvmf_poll_group_remove(struct spdk_nvmf_qpair *qpair); + /** * Get the NVMe-oF subsystem associated with this controller. * diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 257c7a335..ac20178ff 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -880,20 +880,16 @@ _nvmf_ctrlr_free_from_qpair(void *ctx) free(qpair_ctx); } -static void -_nvmf_qpair_destroy(void *ctx, int status) +void +spdk_nvmf_poll_group_remove(struct spdk_nvmf_qpair *qpair) { - 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_nvmf_transport_poll_group *tgroup; struct spdk_nvmf_request *req, *tmp; struct spdk_nvmf_subsystem_poll_group *sgroup; int rc; - assert(qpair->state == SPDK_NVMF_QPAIR_DEACTIVATING); nvmf_qpair_set_state(qpair, SPDK_NVMF_QPAIR_ERROR); - qpair_ctx->qid = qpair->qid; /* Find the tgroup and remove the qpair from the tgroup */ TAILQ_FOREACH(tgroup, &qpair->group->tgroups, link) { @@ -920,6 +916,19 @@ _nvmf_qpair_destroy(void *ctx, int status) } TAILQ_REMOVE(&qpair->group->qpairs, qpair, link); +} + +static void +_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; + + assert(qpair->state == SPDK_NVMF_QPAIR_DEACTIVATING); + qpair_ctx->qid = qpair->qid; + + spdk_nvmf_poll_group_remove(qpair); if (!ctrlr || !ctrlr->thread) { nvmf_transport_qpair_fini(qpair); @@ -932,7 +941,6 @@ _nvmf_qpair_destroy(void *ctx, int status) qpair_ctx->ctrlr = ctrlr; spdk_thread_send_msg(ctrlr->thread, _nvmf_ctrlr_free_from_qpair, qpair_ctx); - } int diff --git a/lib/nvmf/spdk_nvmf.map b/lib/nvmf/spdk_nvmf.map index c2cfa1a07..9f953ec3d 100644 --- a/lib/nvmf/spdk_nvmf.map +++ b/lib/nvmf/spdk_nvmf.map @@ -107,6 +107,7 @@ spdk_nvmf_request_complete; spdk_nvmf_ctrlr_get_subsystem; spdk_nvmf_req_get_xfer; + spdk_nvmf_poll_group_remove; local: *;