nvmf: set NGUID for given namespace based on bdev UUID

If NGUID is not specified with nvmf_subsystem_add_ns json-rpc request
then it is possible to expose the same NGUID as bdev nvme module
attached.

Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com>
Change-Id: Ie0ed7189e55a5abd6bc0904fc356d26f62b50549
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8628
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jacek Kalwas 2021-07-02 08:24:11 -04:00 committed by Tomasz Zawadzki
parent 1f433c4c32
commit 03ac99d13f

View File

@ -1460,6 +1460,12 @@ spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem, const char
opts.uuid = *spdk_bdev_get_uuid(ns->bdev);
}
/* if nguid descriptor is supported by bdev module (nvme) then uuid = nguid */
if (spdk_mem_all_zero(opts.nguid, sizeof(opts.nguid))) {
SPDK_STATIC_ASSERT(sizeof(opts.nguid) == sizeof(opts.uuid), "size mismatch");
memcpy(opts.nguid, spdk_bdev_get_uuid(ns->bdev), sizeof(opts.nguid));
}
ns->opts = opts;
ns->subsystem = subsystem;
subsystem->ns[opts.nsid - 1] = ns;