lib/nvme: Hold ctrlr->ctrlr_lock before calling nvme_ctrlr_fail

Fixes #1615

Signed-off-by: Vasuki Manikarnike <vasuki.manikarnike@hpe.com>
Change-Id: Ib38f38a1086ec804222ccb94dfb3d41a85b62a8d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4608
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Vasuki Manikarnike 2020-10-12 21:14:01 -04:00 committed by Tomasz Zawadzki
parent 2475faff1e
commit ed65607cf9
2 changed files with 6 additions and 0 deletions

View File

@ -550,7 +550,9 @@ nvme_ctrlr_poll_internal(struct spdk_nvme_ctrlr *ctrlr,
/* Controller failed to initialize. */ /* Controller failed to initialize. */
TAILQ_REMOVE(&probe_ctx->init_ctrlrs, ctrlr, tailq); TAILQ_REMOVE(&probe_ctx->init_ctrlrs, ctrlr, tailq);
SPDK_ERRLOG("Failed to initialize SSD: %s\n", ctrlr->trid.traddr); SPDK_ERRLOG("Failed to initialize SSD: %s\n", ctrlr->trid.traddr);
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
nvme_ctrlr_fail(ctrlr, false); nvme_ctrlr_fail(ctrlr, false);
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
nvme_ctrlr_destruct(ctrlr); nvme_ctrlr_destruct(ctrlr);
return rc; return rc;
} }

View File

@ -299,7 +299,9 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx)
SPDK_DEBUGLOG(nvme, "remove nvme address: %s\n", SPDK_DEBUGLOG(nvme, "remove nvme address: %s\n",
event.traddr); event.traddr);
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
nvme_ctrlr_fail(ctrlr, true); nvme_ctrlr_fail(ctrlr, true);
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
/* get the user app to clean up and stop I/O */ /* get the user app to clean up and stop I/O */
if (ctrlr->remove_cb) { if (ctrlr->remove_cb) {
@ -328,7 +330,9 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx)
} }
if (do_remove) { if (do_remove) {
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
nvme_ctrlr_fail(ctrlr, true); nvme_ctrlr_fail(ctrlr, true);
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
if (ctrlr->remove_cb) { if (ctrlr->remove_cb) {
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr); ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr);