From c6d32d39af92352a19bd29a3fc4fe6f7762b6ec5 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 30 Nov 2017 11:16:37 -0700 Subject: [PATCH] lvol: pass UUID as a string in public API Modify the vbdev_get_lvol_store_by_uuid() API function to take the UUID as a string instead of a uuid_t, since this simplifies the calling code. This also allows us to remove #include from the public API, giving us the freedom to change the underlying UUID implementation later if necessary without breaking API. Change-Id: Ib360281f384f95722c5ab64e75dcf3603f826e4c Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/389893 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Maciej Szwed Reviewed-by: Ben Walker --- include/spdk/lvol.h | 6 +++--- include/spdk_internal/lvolstore.h | 2 ++ lib/bdev/lvol/vbdev_lvol.c | 16 ++++++++++++++-- lib/bdev/lvol/vbdev_lvol_rpc.c | 11 ++--------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/spdk/lvol.h b/include/spdk/lvol.h index 7cd26598a..3424a83a7 100644 --- a/include/spdk/lvol.h +++ b/include/spdk/lvol.h @@ -40,7 +40,6 @@ #include "spdk/queue.h" #include "spdk/blob.h" -#include struct spdk_lvol_store; struct spdk_lvol; @@ -188,10 +187,11 @@ struct spdk_lvol *vbdev_get_lvol_by_name(const char *name); /** * \brief Search for handle lvolstore - * \param uuid UUID of lvolstore + * \param uuid_str UUID of lvolstore * \return Handle to spdk_lvol_store or NULL if not found. */ -struct spdk_lvol_store *vbdev_get_lvol_store_by_uuid(uuid_t uuid); +struct spdk_lvol_store *vbdev_get_lvol_store_by_uuid(const char *uuid_str); + /** * \brief Search for handle to lvolstore * \param name name of lvolstore diff --git a/include/spdk_internal/lvolstore.h b/include/spdk_internal/lvolstore.h index ed207621c..9eee8510e 100644 --- a/include/spdk_internal/lvolstore.h +++ b/include/spdk_internal/lvolstore.h @@ -37,6 +37,8 @@ #include "spdk/lvol.h" #include "spdk_internal/bdev.h" +#include + /* Default size of blobstore cluster */ #define SPDK_LVS_OPTS_CLUSTER_SZ (1024 * 1024 * 1024) diff --git a/lib/bdev/lvol/vbdev_lvol.c b/lib/bdev/lvol/vbdev_lvol.c index 4a21f31ef..bf002cf2a 100644 --- a/lib/bdev/lvol/vbdev_lvol.c +++ b/lib/bdev/lvol/vbdev_lvol.c @@ -281,8 +281,8 @@ vbdev_lvol_store_next(struct lvol_store_bdev *prev) return lvs_bdev; } -struct spdk_lvol_store * -vbdev_get_lvol_store_by_uuid(uuid_t uuid) +static struct spdk_lvol_store * +_vbdev_get_lvol_store_by_uuid(uuid_t uuid) { struct spdk_lvol_store *lvs = NULL; struct lvol_store_bdev *lvs_bdev = vbdev_lvol_store_first(); @@ -297,6 +297,18 @@ vbdev_get_lvol_store_by_uuid(uuid_t uuid) return NULL; } +struct spdk_lvol_store * +vbdev_get_lvol_store_by_uuid(const char *uuid_str) +{ + uuid_t uuid; + + if (uuid_parse(uuid_str, uuid)) { + return NULL; + } + + return _vbdev_get_lvol_store_by_uuid(uuid); +} + struct spdk_lvol_store * vbdev_get_lvol_store_by_name(const char *name) { diff --git a/lib/bdev/lvol/vbdev_lvol_rpc.c b/lib/bdev/lvol/vbdev_lvol_rpc.c index 021db0797..464ac7651 100644 --- a/lib/bdev/lvol/vbdev_lvol_rpc.c +++ b/lib/bdev/lvol/vbdev_lvol_rpc.c @@ -50,8 +50,6 @@ static int vbdev_get_lvol_store_by_uuid_xor_name(const char *uuid, const char *lvs_name, struct spdk_lvol_store **lvs) { - uuid_t lvol_store_uuid; - if ((uuid == NULL && lvs_name == NULL)) { SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "lvs UUID nor lvs name specified\n"); return -EINVAL; @@ -60,15 +58,10 @@ vbdev_get_lvol_store_by_uuid_xor_name(const char *uuid, const char *lvs_name, lvs_name); return -EINVAL; } else if (uuid) { - if (uuid_parse(uuid, lvol_store_uuid)) { - SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "incorrect UUID '%s'\n", uuid); - return -EINVAL; - } - - *lvs = vbdev_get_lvol_store_by_uuid(lvol_store_uuid); + *lvs = vbdev_get_lvol_store_by_uuid(uuid); if (*lvs == NULL) { - SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "blobstore with UUID '%p' not found\n", &lvol_store_uuid); + SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "blobstore with UUID '%s' not found\n", uuid); return -ENODEV; } } else if (lvs_name) {