Commit d086d564 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

bdev/nvme: save discovery configuration



We want to be able to save the discovery configuration
in a generated JSON-RPC file.

The obvious change needed here is to add a
bdev_nvme_start_discovery RPC to the config file
for each discovery context.

But we also need to make sure we do not emit
bdev_nvme_attach_controller RPCs for controllers
that were attached via the discovery service.  These
controllers will be attached by the discovery service
instead - or maybe not at all if the discovery
log page returns different results.

Do both of these changes here, since they are
somewhat tied to each other.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent a2d4ddb3
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -5904,12 +5904,45 @@ bdev_nvme_opts_config_json(struct spdk_json_write_ctx *w)
	spdk_json_write_object_end(w);
}

static void
bdev_nvme_discovery_config_json(struct spdk_json_write_ctx *w, struct discovery_ctx *ctx)
{
	struct spdk_nvme_transport_id trid;

	spdk_json_write_object_begin(w);

	spdk_json_write_named_string(w, "method", "bdev_nvme_start_discovery");

	spdk_json_write_named_object_begin(w, "params");
	spdk_json_write_named_string(w, "name", ctx->name);
	spdk_json_write_named_string(w, "hostnqn", ctx->hostnqn);

	trid = ctx->trid;
	memset(trid.subnqn, 0, sizeof(trid.subnqn));
	nvme_bdev_dump_trid_json(&trid, w);

	spdk_json_write_named_int32(w, "ctrlr_loss_timeout_sec", ctx->bdev_opts.ctrlr_loss_timeout_sec);
	spdk_json_write_named_uint32(w, "reconnect_delay_sec", ctx->bdev_opts.reconnect_delay_sec);
	spdk_json_write_named_uint32(w, "fast_io_fail_timeout_sec",
				     ctx->bdev_opts.fast_io_fail_timeout_sec);
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
}

static void
nvme_ctrlr_config_json(struct spdk_json_write_ctx *w,
		       struct nvme_ctrlr *nvme_ctrlr)
{
	struct spdk_nvme_transport_id	*trid;

	if (nvme_ctrlr->opts.from_discovery_service) {
		/* Do not emit an RPC for this - it will be implicitly
		 * covered by a separate bdev_nvme_start_discovery RPC.
		 */
		return;
	}

	trid = &nvme_ctrlr->active_path_id->trid;

	spdk_json_write_object_begin(w);
@@ -5952,6 +5985,7 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
{
	struct nvme_bdev_ctrlr	*nbdev_ctrlr;
	struct nvme_ctrlr	*nvme_ctrlr;
	struct discovery_ctx	*ctx;

	bdev_nvme_opts_config_json(w);

@@ -5963,6 +5997,10 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
		}
	}

	TAILQ_FOREACH(ctx, &g_discovery_ctxs, tailq) {
		bdev_nvme_discovery_config_json(w, ctx);
	}

	/* Dump as last parameter to give all NVMe bdevs chance to be constructed
	 * before enabling hotplug poller.
	 */