From 87ec451b070a85d70f1ec1a357e43302666cd0ac Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 26 Apr 2018 16:59:03 -0700 Subject: [PATCH] Revert "nvmf: disconnect other connections if admin qpair disconnects." This seems to be causing a new intermittent test failure with a call stack that looks like: # nvme disconnect -n nqn.2016-06.io.spdk:cnode1 transport.c:175:23: runtime error: member access within misaligned address 0x000000004321 for type 'const struct spdk_nvmf_transport_ops', which requires 8 byte alignment 0x000000004321: note: pointer points here #0 0x4e014b in spdk_nvmf_transport_qpair_fini #1 0x4f14fe in nvmf_qpair_fini #2 0x502a95 in _spdk_reactor_msg_passed This reverts commit adfa9f6dc75d4c541beeb3269442552f7cbf5d7a. Change-Id: I4bab9d8b5294e241c960683df14acbf457bf3391 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/409251 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/ctrlr.c | 49 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index b558a75a4..0aa8193c1 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -275,13 +275,23 @@ end: } static void -_ctrlr_destruct_check(void *ctx) +ctrlr_delete_qpair(void *ctx) { - struct spdk_nvmf_ctrlr *ctrlr = ctx; + struct spdk_nvmf_qpair *qpair = ctx; + struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr; assert(ctrlr != NULL); assert(ctrlr->num_qpairs > 0); + /* Defer the admin qpair deletion since there are still io qpairs */ + if ((ctrlr->num_qpairs > 1) && (qpair == ctrlr->admin_qpair)) { + spdk_thread_send_msg(qpair->group->thread, ctrlr_delete_qpair, qpair); + return; + } + ctrlr->num_qpairs--; + TAILQ_REMOVE(&ctrlr->qpairs, qpair, link); + spdk_nvmf_transport_qpair_fini(qpair); + if (ctrlr->num_qpairs == 0) { assert(ctrlr->subsys != NULL); assert(ctrlr->subsys->thread != NULL); @@ -289,41 +299,6 @@ _ctrlr_destruct_check(void *ctx) } } -static void -nvmf_qpair_fini(void *ctx) -{ - struct spdk_nvmf_qpair *qpair = ctx; - struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr; - struct spdk_thread *admin_thread = ctrlr->admin_qpair->group->thread; - - spdk_nvmf_transport_qpair_fini(qpair); - spdk_thread_send_msg(admin_thread, _ctrlr_destruct_check, ctrlr); -} - -static void -ctrlr_delete_qpair(void *ctx) -{ - struct spdk_nvmf_qpair *qpair = ctx, *_qpair, *tmp; - struct spdk_nvmf_ctrlr *ctrlr = qpair->ctrlr; - - assert(ctrlr != NULL); - - /* Delete all io qpairs if receving the admin qpair disconnect event early */ - if ((ctrlr->num_qpairs > 1) && (qpair == ctrlr->admin_qpair)) { - TAILQ_FOREACH_SAFE(_qpair, &ctrlr->qpairs, link, tmp) { - if (_qpair != qpair) { - ctrlr_delete_qpair(_qpair); - } - } - - spdk_thread_send_msg(qpair->group->thread, ctrlr_delete_qpair, qpair); - return; - } - - TAILQ_REMOVE(&ctrlr->qpairs, qpair, link); - spdk_thread_send_msg(qpair->group->thread, nvmf_qpair_fini, qpair); -} - static void _spdk_nvmf_ctrlr_add_io_qpair(void *ctx) {