From 187e2dfbbfcd17a9b7b492fd8c9899d5f84dc6ea Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Wed, 5 Dec 2018 23:32:26 -0500 Subject: [PATCH] nvmf: use spdk_uuid_copy() API instead of memcpy. For NVMeoF, extened host identifer is used which is exactly the same size as uuid, while here, use uuid data structure makes sense. For NVMeoF reservation features, host identifier need to be used with each registrant, using spdk_uuid_compare becomes straightforward. Change-Id: Ib6ffaa92fab5e0ae5037682be14fcc415f9714d7 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/436302 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: Jim Harris --- lib/nvmf/ctrlr.c | 4 ++-- lib/nvmf/nvmf_internal.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index f139d3460b..f7e56f2cc0 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -182,7 +182,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem, ctrlr->feat.number_of_queues.bits.nsqr = transport->opts.max_qpairs_per_ctrlr - 1 - 1; - memcpy(ctrlr->hostid, connect_data->hostid, sizeof(ctrlr->hostid)); + spdk_uuid_copy(&ctrlr->hostid, (struct spdk_uuid *)connect_data->hostid); ctrlr->vcprop.cap.raw = 0; ctrlr->vcprop.cap.bits.cqr = 1; /* NVMe-oF specification required */ @@ -855,7 +855,7 @@ spdk_nvmf_ctrlr_get_features_host_identifier(struct spdk_nvmf_request *req) return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; } - memcpy(req->data, ctrlr->hostid, sizeof(ctrlr->hostid)); + spdk_uuid_copy((struct spdk_uuid *)req->data, &ctrlr->hostid); return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; } diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 07c8a316bc..89de3dd2b7 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -216,7 +216,7 @@ struct spdk_nvmf_ctrlr { struct spdk_nvmf_request *aer_req; union spdk_nvme_async_event_completion notice_event; - uint8_t hostid[16]; + struct spdk_uuid hostid; uint16_t changed_ns_list_count; struct spdk_nvme_ns_list changed_ns_list;