From 2da6293e85c16c88cdc6858aaf6017624437518f Mon Sep 17 00:00:00 2001 From: Tomasz Kulasek Date: Wed, 11 Apr 2018 14:27:03 +0200 Subject: [PATCH] lvol: add UUID to lvols snapshots and clones See commit 8887697f8c62 ("bdev/lvol: add UUID to lvols") Change-Id: I8b0c2678678588fc9ab85bfcf19fefffc0e26b0c Signed-off-by: Tomasz Kulasek Reviewed-on: https://review.gerrithub.io/407300 Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- lib/lvol/lvol.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/lvol/lvol.c b/lib/lvol/lvol.c index 88cf4ef33..6142afcf4 100644 --- a/lib/lvol/lvol.c +++ b/lib/lvol/lvol.c @@ -1116,7 +1116,7 @@ spdk_lvol_create_snapshot(struct spdk_lvol *origlvol, const char *snapshot_name, struct spdk_blob *origblob; struct spdk_lvol_with_handle_req *req; struct spdk_blob_xattr_opts snapshot_xattrs; - char *xattr_names = LVOL_NAME; + char *xattr_names[] = {LVOL_NAME, "uuid"}; int rc; if (origlvol == NULL) { @@ -1150,9 +1150,11 @@ spdk_lvol_create_snapshot(struct spdk_lvol *origlvol, const char *snapshot_name, newlvol->lvol_store = origlvol->lvol_store; snprintf(newlvol->name, sizeof(newlvol->name), "%s", snapshot_name); - snapshot_xattrs.count = 1; + spdk_uuid_generate(&newlvol->uuid); + spdk_uuid_fmt_lower(newlvol->uuid_str, sizeof(newlvol->uuid_str), &newlvol->uuid); + snapshot_xattrs.count = SPDK_COUNTOF(xattr_names); snapshot_xattrs.ctx = newlvol; - snapshot_xattrs.names = &xattr_names; + snapshot_xattrs.names = xattr_names; snapshot_xattrs.get_value = spdk_lvol_get_xattr_value; req->lvol = newlvol; req->cb_fn = cb_fn; @@ -1171,7 +1173,7 @@ spdk_lvol_create_clone(struct spdk_lvol *origlvol, const char *clone_name, struct spdk_lvol_store *lvs; struct spdk_blob *origblob; struct spdk_blob_xattr_opts clone_xattrs; - char *xattr_names = LVOL_NAME; + char *xattr_names[] = {LVOL_NAME, "uuid"}; int rc; if (origlvol == NULL) { @@ -1205,9 +1207,11 @@ spdk_lvol_create_clone(struct spdk_lvol *origlvol, const char *clone_name, newlvol->lvol_store = lvs; snprintf(newlvol->name, sizeof(newlvol->name), "%s", clone_name); - clone_xattrs.count = 1; + spdk_uuid_generate(&newlvol->uuid); + spdk_uuid_fmt_lower(newlvol->uuid_str, sizeof(newlvol->uuid_str), &newlvol->uuid); + clone_xattrs.count = SPDK_COUNTOF(xattr_names); clone_xattrs.ctx = newlvol; - clone_xattrs.names = &xattr_names; + clone_xattrs.names = xattr_names; clone_xattrs.get_value = spdk_lvol_get_xattr_value; req->lvol = newlvol; req->cb_fn = cb_fn;