Commit 3ec06180 authored by Changpeng Liu's avatar Changpeng Liu
Browse files

nvmf: add a persist through power loss configuration file when constructing NS



For reservation feature in NVMoF, we can't support the persist through
power loss feature, now we will add the configuration file parameter
with Namespace, after users set the configuration file parameter with
one NS, then the PTPL feature can be enabled.

Change-Id: Id72699093f7e68318b9529f7bacc5c9804f7f86b
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455905


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 37bdd0e8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -562,11 +562,13 @@ void spdk_nvmf_ns_opts_get_defaults(struct spdk_nvmf_ns_opts *opts, size_t opts_
 * \param bdev Block device to add as a namespace.
 * \param opts Namespace options, or NULL to use defaults.
 * \param opts_size sizeof(*opts)
 * \param ptpl_file Persist through power loss file path.
 *
 * \return newly added NSID on success, or 0 on failure.
 */
uint32_t spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bdev *bdev,
				    const struct spdk_nvmf_ns_opts *opts, size_t opts_size);
				    const struct spdk_nvmf_ns_opts *opts, size_t opts_size,
				    const char *ptpl_file);

/**
 * Remove a namespace from a subsytem.
+1 −1
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
			}
		}

		if (spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts)) == 0) {
		if (spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts), NULL) == 0) {
			SPDK_ERRLOG("Unable to add namespace\n");
			spdk_nvmf_subsystem_destroy(subsystem);
			subsystem = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -895,7 +895,7 @@ nvmf_rpc_ns_paused(struct spdk_nvmf_subsystem *subsystem,
		ns_opts.uuid = ctx->ns_params.uuid;
	}

	ctx->ns_params.nsid = spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts));
	ctx->ns_params.nsid = spdk_nvmf_subsystem_add_ns(subsystem, bdev, &ns_opts, sizeof(ns_opts), NULL);
	if (ctx->ns_params.nsid == 0) {
		SPDK_ERRLOG("Unable to add namespace\n");
		spdk_jsonrpc_send_error_response(ctx->request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
+2 −0
Original line number Diff line number Diff line
@@ -217,6 +217,8 @@ struct spdk_nvmf_ns {
	enum spdk_nvme_reservation_type rtype;
	/* current reservation holder, only valid if reservation type can only have one holder */
	struct spdk_nvmf_registrant *holder;
	/* Persist Through Power Loss file which contains the persistent reservation */
	char *ptpl_file;
};

struct spdk_nvmf_qpair {
+9 −1
Original line number Diff line number Diff line
@@ -928,6 +928,9 @@ _spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t n
	}
	spdk_bdev_module_release_bdev(ns->bdev);
	spdk_bdev_close(ns->desc);
	if (ns->ptpl_file) {
		free(ns->ptpl_file);
	}
	free(ns);

	spdk_nvmf_subsystem_ns_changed(subsystem, nsid);
@@ -1007,7 +1010,8 @@ static struct spdk_bdev_module ns_bdev_module = {

uint32_t
spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bdev *bdev,
			   const struct spdk_nvmf_ns_opts *user_opts, size_t opts_size)
			   const struct spdk_nvmf_ns_opts *user_opts, size_t opts_size,
			   const char *ptpl_file)
{
	struct spdk_nvmf_ns_opts opts;
	struct spdk_nvmf_ns *ns;
@@ -1104,6 +1108,10 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
	ns->nsid = opts.nsid;
	TAILQ_INIT(&ns->registrants);

	if (ptpl_file) {
		ns->ptpl_file = strdup(ptpl_file);
	}

	SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Subsystem %s: bdev %s assigned nsid %" PRIu32 "\n",
		      spdk_nvmf_subsystem_get_nqn(subsystem),
		      spdk_bdev_get_name(bdev),
Loading