Commit afdec00e authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

nvmf: Add hide_metadata option to nvmf_subsystem_add_ns



Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I518c3cc5fdcb16b41f1e3bda1debf5cb3cc9c47b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25413


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent b09de013
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8666,6 +8666,7 @@ eui64 | Optional | string | 8-byte namespace EUI-64 in he
uuid                    | Optional | string      | RFC 4122 UUID (e.g. "ceccf520-691e-4b46-9546-34af789907c5")
ptpl_file               | Optional | string      | File path to save/restore persistent reservation information
anagrpid                | Optional | number      | ANA group ID. Default: Namespace ID.
hide_metadata           | Optional | bool        | Enable hide_metadata option to the bdev. Default: false

#### Example

+6 −1
Original line number Diff line number Diff line
@@ -1060,8 +1060,13 @@ struct spdk_nvmf_ns_opts {
	 * after namespace has been added object becomes invalid.
	 */
	const struct spdk_json_val *transport_specific;

	/**
	 * Enable hide_metadata option to the bdev.
	 */
	bool hide_metadata;
} __attribute__((packed));
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_ns_opts) == 72, "Incorrect size");
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_ns_opts) == 73, "Incorrect size");

/**
 * Get default namespace creation options.
+3 −0
Original line number Diff line number Diff line
@@ -1377,6 +1377,7 @@ struct nvmf_rpc_ns_params {
	struct spdk_uuid uuid;
	uint32_t anagrpid;
	bool no_auto_visible;
	bool hide_metadata;
};

static const struct spdk_json_object_decoder rpc_ns_params_decoders[] = {
@@ -1388,6 +1389,7 @@ static const struct spdk_json_object_decoder rpc_ns_params_decoders[] = {
	{"uuid", offsetof(struct nvmf_rpc_ns_params, uuid), spdk_json_decode_uuid, true},
	{"anagrpid", offsetof(struct nvmf_rpc_ns_params, anagrpid), spdk_json_decode_uint32, true},
	{"no_auto_visible", offsetof(struct nvmf_rpc_ns_params, no_auto_visible), spdk_json_decode_bool, true},
	{"hide_metadata", offsetof(struct nvmf_rpc_ns_params, hide_metadata), spdk_json_decode_bool, true},
};

static int
@@ -1509,6 +1511,7 @@ nvmf_rpc_ns_paused(struct spdk_nvmf_subsystem *subsystem,

	ns_opts.anagrpid = ctx->ns_params.anagrpid;
	ns_opts.no_auto_visible = ctx->ns_params.no_auto_visible;
	ns_opts.hide_metadata = ctx->ns_params.hide_metadata;

	ctx->ns_params.nsid = spdk_nvmf_subsystem_add_ns_ext(subsystem, ctx->ns_params.bdev_name,
			      &ns_opts, sizeof(ns_opts),
+8 −2
Original line number Diff line number Diff line
@@ -1996,6 +1996,7 @@ spdk_nvmf_ns_opts_get_defaults(struct spdk_nvmf_ns_opts *opts, size_t opts_size)
	}
	SET_FIELD(anagrpid, 0);
	SET_FIELD(transport_specific, NULL);
	SET_FIELD(hide_metadata, false);

#undef FIELD_OK
#undef SET_FIELD
@@ -2027,13 +2028,14 @@ nvmf_ns_opts_copy(struct spdk_nvmf_ns_opts *opts,
	SET_FIELD(anagrpid);
	SET_FIELD(no_auto_visible);
	SET_FIELD(transport_specific);
	SET_FIELD(hide_metadata);

	opts->opts_size = user_opts->opts_size;

	/* We should not remove this statement, but need to update the assert statement
	 * if we add a new field, and also add a corresponding SET_FIELD statement.
	 */
	SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_ns_opts) == 72, "Incorrect size");
	SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_ns_opts) == 73, "Incorrect size");

#undef FIELD_OK
#undef SET_FIELD
@@ -2075,6 +2077,7 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
{
	struct spdk_nvmf_transport *transport;
	struct spdk_nvmf_ns_opts opts;
	struct spdk_bdev_open_opts open_opts = {};
	struct spdk_nvmf_ns *ns, *first_ns;
	struct spdk_nvmf_ctrlr *ctrlr;
	struct spdk_nvmf_reservation_info info = {0};
@@ -2145,7 +2148,10 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
		nvmf_ctrlr_ns_set_visible(ctrlr, opts.nsid, ns->always_visible);
	}

	rc = spdk_bdev_open_ext(bdev_name, true, nvmf_ns_event, ns, &ns->desc);
	spdk_bdev_open_opts_init(&open_opts, sizeof(open_opts));
	open_opts.hide_metadata = opts.hide_metadata;

	rc = spdk_bdev_open_ext_v2(bdev_name, true, nvmf_ns_event, ns, &open_opts, &ns->desc);
	if (rc != 0) {
		SPDK_ERRLOG("Subsystem %s: bdev %s cannot be opened, error=%d\n",
			    subsystem->subnqn, bdev_name, rc);
+4 −2
Original line number Diff line number Diff line
@@ -473,7 +473,8 @@ def nvmf_subsystem_add_ns(client, **params):
        eui64: 8-byte namespace EUI-64 in hexadecimal (e.g. "ABCDEF0123456789") (optional).
        uuid: Namespace UUID (optional).
        anagrpid: ANA group ID (optional).
        no_auto_visible: Do not automatically make namespace visible to controllers
        no_auto_visible: Do not automatically make namespace visible to controllers (optional)
        hide_metadata: Enable hide_metadata option to the bdev (optional)

    Returns:
        The namespace ID
@@ -482,7 +483,8 @@ def nvmf_subsystem_add_ns(client, **params):
    strip_globals(params)
    apply_defaults(params, tgt_name=None)
    group_as(params, 'namespace', ['bdev_name', 'ptpl_file', 'nsid',
                                   'nguid', 'eui64', 'uuid', 'anagrpid', 'no_auto_visible'])
                                   'nguid', 'eui64', 'uuid', 'anagrpid', 'no_auto_visible',
                                   'hide_metadata'])
    remove_null(params)

    return client.call('nvmf_subsystem_add_ns', params)
Loading