Commit c179c2ad authored by Marcin Spiewak's avatar Marcin Spiewak Committed by Konrad Sztyber
Browse files

bdev/nvme: save config for failover controllers



This patch fixes the issue where configuration for
controllers in 'failover' mode was not saved when
save_config RPC command was issued.
The issue here is that if additional controller is
added by bdev_nvme_attach_controller RPC with the same
controller name and different transport parameters, the
intention is to not add a new controller, but rather specify
addional transport for failover functionality. Internally
only one controller exists but alternate transports to target
are defined. Therefore during generation of config file
only one bdev_nvme_attach_controller command was generated,
due to only one controller existing.
This hovever caused that alternate transports were not saved
and could not be restored from saved configuration, because
they didn't existed there.
Now it is fixed, and for every active and alternate transports
defined for controller, separate bdev_nvme_attach_controller
commands are generated (with the same controller parameters
but different transport description) so after loading config
from JSON file, proper alternate trids are restored for
failover mode.

Change-Id: I7af826f3873e524b85aa578dcd81cd9e2cab6e06
Signed-off-by: default avatarMarcin Spiewak <marcin.spiewak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24764


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 733a8d23
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -8610,7 +8610,8 @@ nvme_ctrlr_cuse_config_json(struct spdk_json_write_ctx *w,

static void
nvme_ctrlr_config_json(struct spdk_json_write_ctx *w,
		       struct nvme_ctrlr *nvme_ctrlr)
		       struct nvme_ctrlr *nvme_ctrlr,
		       struct nvme_path_id *path_id)
{
	struct spdk_nvme_transport_id	*trid;
	const struct spdk_nvme_ctrlr_opts *opts;
@@ -8623,7 +8624,7 @@ nvme_ctrlr_config_json(struct spdk_json_write_ctx *w,
		return;
	}

	trid = &nvme_ctrlr->active_path_id->trid;
	trid = &path_id->trid;

	spdk_json_write_object_begin(w);

@@ -8682,6 +8683,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;
	struct nvme_path_id	*path_id;

	bdev_nvme_opts_config_json(w);

@@ -8689,7 +8691,15 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)

	TAILQ_FOREACH(nbdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
		TAILQ_FOREACH(nvme_ctrlr, &nbdev_ctrlr->ctrlrs, tailq) {
			nvme_ctrlr_config_json(w, nvme_ctrlr);
			path_id = nvme_ctrlr->active_path_id;
			assert(path_id == TAILQ_FIRST(&nvme_ctrlr->trids));
			nvme_ctrlr_config_json(w, nvme_ctrlr, path_id);

			path_id = TAILQ_NEXT(path_id, link);
			while (path_id != NULL) {
				nvme_ctrlr_config_json(w, nvme_ctrlr, path_id);
				path_id = TAILQ_NEXT(path_id, link);
			}

#ifdef SPDK_CONFIG_NVME_CUSE
			nvme_ctrlr_cuse_config_json(w, nvme_ctrlr);