nvme: store the probe destroy_cb in the ctrlr.

Making this structure available from the ctrlr allows us to call the
remove callback when the controller is failed/removed on transports
other than pcie.

Change-Id: I2c66dfef12b039c0d6daf7df83da745757818006
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469636
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Seth Howell 2019-09-26 14:29:18 -07:00 committed by Jim Harris
parent 2476a74550
commit d7d03bd36a
3 changed files with 10 additions and 4 deletions

View File

@ -426,6 +426,8 @@ nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid,
SPDK_ERRLOG("Failed to construct NVMe controller for SSD: %s\n", trid->traddr);
return -1;
}
ctrlr->remove_cb = probe_ctx->remove_cb;
ctrlr->cb_ctx = probe_ctx->cb_ctx;
TAILQ_INSERT_TAIL(&probe_ctx->init_ctrlrs, ctrlr, tailq);
return 0;

View File

@ -701,6 +701,10 @@ struct spdk_nvme_ctrlr {
STAILQ_HEAD(, nvme_request) queued_aborts;
uint32_t outstanding_aborts;
/* CB to notify the user when the ctrlr is removed/failed. */
spdk_nvme_remove_cb remove_cb;
void *cb_ctx;
};
struct spdk_nvme_probe_ctx {

View File

@ -299,9 +299,9 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx)
nvme_ctrlr_fail(ctrlr, true);
/* get the user app to clean up and stop I/O */
if (probe_ctx->remove_cb) {
if (ctrlr->remove_cb) {
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
probe_ctx->remove_cb(probe_ctx->cb_ctx, ctrlr);
ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr);
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
}
}
@ -331,9 +331,9 @@ _nvme_pcie_hotplug_monitor(struct spdk_nvme_probe_ctx *probe_ctx)
if (do_remove) {
nvme_ctrlr_fail(ctrlr, true);
if (probe_ctx->remove_cb) {
if (ctrlr->remove_cb) {
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
probe_ctx->remove_cb(probe_ctx->cb_ctx, ctrlr);
ctrlr->remove_cb(probe_ctx->cb_ctx, ctrlr);
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
}
}