Commit d7d03bd3 authored by Seth Howell's avatar Seth Howell Committed by Jim Harris
Browse files

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: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469636


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 2476a745
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
+4 −0
Original line number Diff line number Diff line
@@ -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 {
+4 −4
Original line number Diff line number Diff line
@@ -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);
			}
		}