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

bdev/nvme: save config for multipath mode



This patch fixes the issue where configuration for
controllers in multipath mode was not saved when
save_config RPC command was issued.
Now there is a flag added to controller options
structure that stores the multipath state for the
controller.
If a controller is added by bdev_nvme_attach_controller RPC
call with '-x multipath' parameter, the flag is set to true
and when save_config RPC is issued, this flag is used to
generate appropriate field in JSON file. This JSON file
can be then loaded when a target is starting, to restore
saved configuration.
Note: the order of creating controllers matters for multipath.
The '-x multipath' parameter shall be specified for second
(and subsequent controllers) created. If first controller
is created by bdev_nvme_attach_controller RPC with
'-x multipath' parameter, and then second controller is added
with the same controller name and different transport parameters
but without '-x multipath' parameter, the controllers will act
as if they were created in 'failover' mode.

Fixes #3502

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


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent c179c2ad
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ struct spdk_bdev_nvme_ctrlr_opts {
	 * These will only support NVMe passthrough.
	 */
	bool allow_unrecognized_csi;

	/* Set to true if multipath enabled */
	bool multipath;
};

/**
+4 −0
Original line number Diff line number Diff line
@@ -5761,6 +5761,7 @@ spdk_bdev_nvme_get_default_ctrlr_opts(struct spdk_bdev_nvme_ctrlr_opts *opts)
	opts->ctrlr_loss_timeout_sec = g_opts.ctrlr_loss_timeout_sec;
	opts->reconnect_delay_sec = g_opts.reconnect_delay_sec;
	opts->fast_io_fail_timeout_sec = g_opts.fast_io_fail_timeout_sec;
	opts->multipath = false;
}

static void
@@ -8658,6 +8659,9 @@ nvme_ctrlr_config_json(struct spdk_json_write_ctx *w,
		spdk_json_write_named_string(w, "hostsvcid", opts->src_svcid);
	}

	if (nvme_ctrlr->opts.multipath) {
		spdk_json_write_named_string(w, "multipath", "multipath");
	}
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
+1 −0
Original line number Diff line number Diff line
@@ -623,6 +623,7 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
	ctx->req.bdev_opts.from_discovery_service = false;
	ctx->req.bdev_opts.dhchap_key = ctx->req.dhchap_key;
	ctx->req.bdev_opts.dhchap_ctrlr_key = ctx->req.dhchap_ctrlr_key;
	ctx->req.bdev_opts.multipath = multipath;
	rc = spdk_bdev_nvme_create(&trid, ctx->req.name, ctx->names, ctx->req.max_bdevs,
				   rpc_bdev_nvme_attach_controller_done, ctx, &ctx->req.drv_opts,
				   &ctx->req.bdev_opts, multipath);