Commit 68e5f0ae authored by Jim Harris's avatar Jim Harris
Browse files

bdev/nvme: add detach step to discovery_poller



If a discovery controller fails at some point, we
will want to detach it.  This can happen separately
from detaching the controller because we are stopping
the discovery service.  So break out the ctrlr
detach operation into a separate phase of the
discovery_poller.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ia601b767d32bda1c8899d3a95029781c0aeee136
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11772


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 7dfe90df
Loading
Loading
Loading
Loading
+15 −20
Original line number Diff line number Diff line
@@ -4644,29 +4644,24 @@ discovery_poller(void *arg)
	struct spdk_nvme_transport_id *trid;
	int rc;

	if (ctx->stop) {
		bool detach_done = false;

		if (ctx->ctrlr == NULL) {
			detach_done = true;
		} else if (ctx->detach_ctx == NULL) {
			rc = spdk_nvme_detach_async(ctx->ctrlr, &ctx->detach_ctx);
			if (rc != 0) {
				DISCOVERY_ERRLOG(ctx, "could not detach discovery ctrlr\n");
				detach_done = true;
			}
		} else {
	if (ctx->detach_ctx) {
		rc = spdk_nvme_detach_poll_async(ctx->detach_ctx);
		if (rc != -EAGAIN) {
				detach_done = true;
			ctx->detach_ctx = NULL;
			ctx->ctrlr = NULL;
		}
	} else if (ctx->stop) {
		if (ctx->ctrlr != NULL) {
			rc = spdk_nvme_detach_async(ctx->ctrlr, &ctx->detach_ctx);
			if (rc == 0) {
				return SPDK_POLLER_BUSY;
			}
			DISCOVERY_ERRLOG(ctx, "could not detach discovery ctrlr\n");
		}
		if (detach_done) {
		spdk_poller_unregister(&ctx->poller);
		TAILQ_REMOVE(&g_discovery_ctxs, ctx, tailq);
		ctx->stop_cb_fn(ctx->cb_ctx);
		free_discovery_ctx(ctx);
		}
	} else if (ctx->probe_ctx == NULL && ctx->ctrlr == NULL) {
		assert(ctx->entry_ctx_in_use == NULL);
		ctx->entry_ctx_in_use = TAILQ_FIRST(&ctx->discovery_entry_ctxs);