From 85d9f0a9ab4e83e7825f761c72ebba452482cf4a Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Fri, 11 Oct 2019 13:42:54 -0700 Subject: [PATCH] Revert "nvme: call the remove_cb in nvme_ctrlr_fail." This reverts commit bc4e31d6b24d08aa20a1166215e0131f72c7c36e. This change was accidentally merged after it was decided to go with a different architecture. Change-Id: Ifc9d8b08bd1fcbc4ace8dd6fb4bd0014330916ed Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471144 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- lib/nvme/nvme_ctrlr.c | 30 ------------------------------ lib/nvme/nvme_pcie.c | 13 ++++++++++++- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index fad4dd67f..524fbb8a7 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -585,8 +585,6 @@ nvme_ctrlr_set_supported_features(struct spdk_nvme_ctrlr *ctrlr) void nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr, bool hot_remove) { - int had_lock; - /* * Set the flag here and leave the work failure of qpairs to * spdk_nvme_qpair_process_completions(). @@ -594,36 +592,8 @@ nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr, bool hot_remove) if (hot_remove) { ctrlr->is_removed = true; } - - /* - * Return if we have already set the state to failed since we - * don't want to call the disconnect callback twice. - */ - if (ctrlr->is_failed) { - return; - } ctrlr->is_failed = true; SPDK_ERRLOG("ctrlr %s in failed state.\n", ctrlr->trid.traddr); - - if (ctrlr->remove_cb == NULL) { - return; - } - - /* - * In the pcie hotplug case, this function may be called with the - * global driver lock. In that case, we want to make sure that we - * release it before calling the remove callback and restore the - * old state afterwards. - * robust locks return EPERM if we try to unlock a lock we - * aren't holding. - */ - had_lock = (nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock) == 0); - - ctrlr->remove_cb(ctrlr->cb_ctx, ctrlr); - - if (had_lock) { - nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock); - } } static void diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 91a598acf..d830e4af5 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -296,8 +296,14 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx) SPDK_DEBUGLOG(SPDK_LOG_NVME, "remove nvme address: %s\n", event.traddr); - /* get the user app to clean up and stop I/O. */ nvme_ctrlr_fail(ctrlr, true); + + /* get the user app to clean up and stop I/O */ + if (ctrlr->remove_cb) { + nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); + ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr); + nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock); + } } } } @@ -325,6 +331,11 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx) if (do_remove) { nvme_ctrlr_fail(ctrlr, true); + if (ctrlr->remove_cb) { + nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); + ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr); + nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock); + } } } return 0;