From bf41a942169611b260855fc8f1875fb476a998df Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 15 Mar 2018 13:57:51 -0700 Subject: [PATCH] lvol: use per-lvol uuid as unique_id if available For old lvols that were generated before the per-lvol uuid was added, the original lvolstore uuid + blob ID unique_id will still be used. Change-Id: Id0f23836ff6fc8886d313f9e3d03e8b7204de2a2 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/404033 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/lvol/lvol.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/lvol/lvol.c b/lib/lvol/lvol.c index 23a7ade9e..283c68a79 100644 --- a/lib/lvol/lvol.c +++ b/lib/lvol/lvol.c @@ -202,8 +202,12 @@ _spdk_load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno) } spdk_uuid_fmt_lower(lvol->uuid_str, sizeof(lvol->uuid_str), &lvol->uuid); - spdk_uuid_fmt_lower(uuid, sizeof(uuid), &lvol->lvol_store->uuid); - lvol->unique_id = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id); + if (!spdk_mem_all_zero(&lvol->uuid, sizeof(lvol->uuid))) { + lvol->unique_id = strdup(lvol->uuid_str); + } else { + spdk_uuid_fmt_lower(uuid, sizeof(uuid), &lvol->lvol_store->uuid); + lvol->unique_id = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id); + } if (!lvol->unique_id) { SPDK_ERRLOG("Cannot assign lvol name\n"); free(lvol); @@ -952,7 +956,6 @@ _spdk_lvol_create_open_cb(void *cb_arg, struct spdk_blob *blob, int lvolerrno) struct spdk_lvol_with_handle_req *req = cb_arg; spdk_blob_id blob_id = spdk_blob_get_id(blob); struct spdk_lvol *lvol = req->lvol; - char uuid[SPDK_UUID_STRING_LEN]; if (lvolerrno < 0) { free(lvol); @@ -966,8 +969,7 @@ _spdk_lvol_create_open_cb(void *cb_arg, struct spdk_blob *blob, int lvolerrno) TAILQ_INSERT_TAIL(&lvol->lvol_store->lvols, lvol, link); - spdk_uuid_fmt_lower(uuid, sizeof(uuid), &lvol->lvol_store->uuid); - lvol->unique_id = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id); + lvol->unique_id = strdup(lvol->uuid_str); if (!lvol->unique_id) { SPDK_ERRLOG("Cannot alloc memory for lvol name\n"); spdk_blob_close(blob, _spdk_lvol_destroy_cb, req);