bdev/nvme: prefer NGUID over UUID if supported

NVMe specification defines namespace identification descriptors i.e.
EUI64, NGUID, UUID.

BDEV abstracts NVMe specific details that is why only UUID is exposed,
however if NGUID is supported it is prefered to identify namespace
with NGUID over UUID.

If NGUID is not supported by NVMe Controller then fallback to UUID.

Signed-off-by: Jacek Kalwas <jacek.kalwas@intel.com>
Change-Id: If51889a3664c0daa7cbe983048231793e3c502e0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8627
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:07:15 -04:00 committed by Tomasz Zawadzki
parent a410fb4438
commit 1f433c4c32
2 changed files with 11 additions and 3 deletions

View File

@ -1351,6 +1351,7 @@ nvme_disk_create(struct spdk_bdev *disk, const char *base_name,
uint32_t prchk_flags, void *ctx)
{
const struct spdk_uuid *uuid;
const uint8_t *nguid;
const struct spdk_nvme_ctrlr_data *cdata;
const struct spdk_nvme_ns_data *nsdata;
int rc;
@ -1395,9 +1396,14 @@ nvme_disk_create(struct spdk_bdev *disk, const char *base_name,
disk->blockcnt = spdk_nvme_ns_get_num_sectors(ns);
disk->optimal_io_boundary = spdk_nvme_ns_get_optimal_io_boundary(ns);
uuid = spdk_nvme_ns_get_uuid(ns);
if (uuid != NULL) {
disk->uuid = *uuid;
nguid = spdk_nvme_ns_get_nguid(ns);
if (!nguid) {
uuid = spdk_nvme_ns_get_uuid(ns);
if (uuid) {
disk->uuid = *uuid;
}
} else {
memcpy(&disk->uuid, nguid, sizeof(disk->uuid));
}
nsdata = spdk_nvme_ns_get_data(ns);

View File

@ -186,6 +186,8 @@ DEFINE_STUB(spdk_nvme_zns_reset_zone, int,
(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, uint64_t slba,
bool select_all, spdk_nvme_cmd_cb cb_fn, void *cb_arg), 0);
DEFINE_STUB(spdk_nvme_ns_get_nguid, const uint8_t *, (const struct spdk_nvme_ns *ns), NULL);
DEFINE_STUB(spdk_nvme_zns_offline_zone, int,
(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair, uint64_t slba,
bool select_all, spdk_nvme_cmd_cb cb_fn, void *cb_arg), 0);