diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index 2ce9793fc..d4fee8c3a 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -550,7 +550,9 @@ nvme_ctrlr_poll_internal(struct spdk_nvme_ctrlr *ctrlr, /* Controller failed to initialize. */ TAILQ_REMOVE(&probe_ctx->init_ctrlrs, ctrlr, tailq); SPDK_ERRLOG("Failed to initialize SSD: %s\n", ctrlr->trid.traddr); + nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); nvme_ctrlr_fail(ctrlr, false); + nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); nvme_ctrlr_destruct(ctrlr); return rc; } diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index b16561e9e..b789ffe30 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -299,7 +299,9 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx) SPDK_DEBUGLOG(nvme, "remove nvme address: %s\n", event.traddr); + nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); nvme_ctrlr_fail(ctrlr, true); + nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); /* get the user app to clean up and stop I/O */ if (ctrlr->remove_cb) { @@ -328,7 +330,9 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx) } if (do_remove) { + nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); nvme_ctrlr_fail(ctrlr, true); + nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); if (ctrlr->remove_cb) { nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr);