nvmf: allow overriding namespace UUID in RPCs
The default is still to retrieve the bdev UUID, but now the end user may also specify their own UUID if desired when adding NVMe-oF target namespaces via construct_nvmf_subsystem or nvmf_subsystem_add_ns. Change-Id: I950eb84b9fdecbc2eae8ca39d9acd6acabe8d31d Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/414269 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
69fa57cdf0
commit
57ae6bf646
@ -345,6 +345,7 @@ nsid | Optional | number | Namespace ID between 1 and 42
|
|||||||
bdev_name | Required | string | Name of bdev to expose as a namespace.
|
bdev_name | Required | string | Name of bdev to expose as a namespace.
|
||||||
nguid | Optional | string | 16-byte namespace globally unique identifier in hexadecimal (e.g. "ABCDEF0123456789ABCDEF0123456789")
|
nguid | Optional | string | 16-byte namespace globally unique identifier in hexadecimal (e.g. "ABCDEF0123456789ABCDEF0123456789")
|
||||||
eui64 | Optional | string | 8-byte namespace EUI-64 in hexadecimal (e.g. "ABCDEF0123456789")
|
eui64 | Optional | string | 8-byte namespace EUI-64 in hexadecimal (e.g. "ABCDEF0123456789")
|
||||||
|
uuid | Optional | string | RFC 4122 UUID (e.g. "ceccf520-691e-4b46-9546-34af789907c5")
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
|
@ -166,6 +166,21 @@ decode_ns_eui64(const struct spdk_json_val *val, void *out)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
decode_ns_uuid(const struct spdk_json_val *val, void *out)
|
||||||
|
{
|
||||||
|
char *str = NULL;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = spdk_json_decode_string(val, &str);
|
||||||
|
if (rc == 0) {
|
||||||
|
rc = spdk_uuid_parse(out, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(str);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_nvmf_subsystem(struct spdk_json_write_ctx *w, struct spdk_nvmf_subsystem *subsystem)
|
dump_nvmf_subsystem(struct spdk_json_write_ctx *w, struct spdk_nvmf_subsystem *subsystem)
|
||||||
{
|
{
|
||||||
@ -424,6 +439,7 @@ struct spdk_nvmf_ns_params {
|
|||||||
uint32_t nsid;
|
uint32_t nsid;
|
||||||
char nguid[16];
|
char nguid[16];
|
||||||
char eui64[8];
|
char eui64[8];
|
||||||
|
struct spdk_uuid uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rpc_namespaces {
|
struct rpc_namespaces {
|
||||||
@ -437,6 +453,7 @@ static const struct spdk_json_object_decoder rpc_ns_params_decoders[] = {
|
|||||||
{"bdev_name", offsetof(struct spdk_nvmf_ns_params, bdev_name), spdk_json_decode_string},
|
{"bdev_name", offsetof(struct spdk_nvmf_ns_params, bdev_name), spdk_json_decode_string},
|
||||||
{"nguid", offsetof(struct spdk_nvmf_ns_params, nguid), decode_ns_nguid, true},
|
{"nguid", offsetof(struct spdk_nvmf_ns_params, nguid), decode_ns_nguid, true},
|
||||||
{"eui64", offsetof(struct spdk_nvmf_ns_params, eui64), decode_ns_eui64, true},
|
{"eui64", offsetof(struct spdk_nvmf_ns_params, eui64), decode_ns_eui64, true},
|
||||||
|
{"uuid", offsetof(struct spdk_nvmf_ns_params, uuid), decode_ns_uuid, true},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -717,6 +734,10 @@ spdk_rpc_construct_nvmf_subsystem(struct spdk_jsonrpc_request *request,
|
|||||||
SPDK_STATIC_ASSERT(sizeof(ns_opts.eui64) == sizeof(ns_params->eui64), "size mismatch");
|
SPDK_STATIC_ASSERT(sizeof(ns_opts.eui64) == sizeof(ns_params->eui64), "size mismatch");
|
||||||
memcpy(ns_opts.eui64, ns_params->eui64, sizeof(ns_opts.eui64));
|
memcpy(ns_opts.eui64, ns_params->eui64, sizeof(ns_opts.eui64));
|
||||||
|
|
||||||
|
if (!spdk_mem_all_zero(&ns_params->uuid, sizeof(ns_params->uuid))) {
|
||||||
|
ns_opts.uuid = ns_params->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
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)) == 0) {
|
||||||
SPDK_ERRLOG("Unable to add namespace\n");
|
SPDK_ERRLOG("Unable to add namespace\n");
|
||||||
spdk_nvmf_subsystem_destroy(subsystem);
|
spdk_nvmf_subsystem_destroy(subsystem);
|
||||||
@ -1126,6 +1147,10 @@ nvmf_rpc_ns_paused(struct spdk_nvmf_subsystem *subsystem,
|
|||||||
SPDK_STATIC_ASSERT(sizeof(ns_opts.eui64) == sizeof(ctx->ns_params.eui64), "size mismatch");
|
SPDK_STATIC_ASSERT(sizeof(ns_opts.eui64) == sizeof(ctx->ns_params.eui64), "size mismatch");
|
||||||
memcpy(ns_opts.eui64, ctx->ns_params.eui64, sizeof(ns_opts.eui64));
|
memcpy(ns_opts.eui64, ctx->ns_params.eui64, sizeof(ns_opts.eui64));
|
||||||
|
|
||||||
|
if (!spdk_mem_all_zero(&ctx->ns_params.uuid, sizeof(ctx->ns_params.uuid))) {
|
||||||
|
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));
|
||||||
if (ctx->ns_params.nsid == 0) {
|
if (ctx->ns_params.nsid == 0) {
|
||||||
SPDK_ERRLOG("Unable to add namespace\n");
|
SPDK_ERRLOG("Unable to add namespace\n");
|
||||||
|
@ -895,6 +895,7 @@ if __name__ == "__main__":
|
|||||||
p.add_argument('-n', '--nsid', help='The requested NSID (optional)', type=int)
|
p.add_argument('-n', '--nsid', help='The requested NSID (optional)', type=int)
|
||||||
p.add_argument('-g', '--nguid', help='Namespace globally unique identifier (optional)')
|
p.add_argument('-g', '--nguid', help='Namespace globally unique identifier (optional)')
|
||||||
p.add_argument('-e', '--eui64', help='Namespace EUI-64 identifier (optional)')
|
p.add_argument('-e', '--eui64', help='Namespace EUI-64 identifier (optional)')
|
||||||
|
p.add_argument('-u', '--uuid', help='Namespace UUID (optional)')
|
||||||
p.set_defaults(func=nvmf_subsystem_add_ns)
|
p.set_defaults(func=nvmf_subsystem_add_ns)
|
||||||
|
|
||||||
@call_cmd
|
@call_cmd
|
||||||
|
@ -84,6 +84,9 @@ def nvmf_subsystem_add_ns(client, args):
|
|||||||
if args.eui64:
|
if args.eui64:
|
||||||
ns['eui64'] = args.eui64
|
ns['eui64'] = args.eui64
|
||||||
|
|
||||||
|
if args.uuid:
|
||||||
|
ns['uuid'] = args.uuid
|
||||||
|
|
||||||
params = {'nqn': args.nqn,
|
params = {'nqn': args.nqn,
|
||||||
'namespace': ns}
|
'namespace': ns}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user