diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 19ed298dd1..aebb981d0c 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -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); diff --git a/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c b/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c index 769a4e5987..36ed22f4ec 100644 --- a/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c +++ b/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c @@ -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);