Commit c6d32d39 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

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 <uuid/uuid.h> 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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/389893


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent f5acc372
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@

#include "spdk/queue.h"
#include "spdk/blob.h"
#include <uuid/uuid.h>

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
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@
#include "spdk/lvol.h"
#include "spdk_internal/bdev.h"

#include <uuid/uuid.h>

/* Default size of blobstore cluster */
#define SPDK_LVS_OPTS_CLUSTER_SZ (1024 * 1024 * 1024)

+14 −2
Original line number Diff line number Diff line
@@ -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)
{
+2 −9
Original line number Diff line number Diff line
@@ -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) {