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

bdev: add spdk_bdev_get_uuid() function



Add a generic way to get a UUID from a bdev.

For now, malloc and null bdevs generate random UUIDs, and no other bdev
types report a UUID.

Change-Id: Id9608c8c1b3ce3f1783e7f74bef96d44cd5d98a7
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/402177


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 4c06ce9b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ struct spdk_bdev_io;
struct spdk_bdev_fn_table;
struct spdk_io_channel;
struct spdk_json_write_ctx;
struct spdk_uuid;

/** bdev status */
enum spdk_bdev_status {
@@ -303,6 +304,17 @@ uint32_t spdk_bdev_get_optimal_io_boundary(const struct spdk_bdev *bdev);
 */
bool spdk_bdev_has_write_cache(const struct spdk_bdev *bdev);

/**
 * Get a bdev's UUID.
 *
 * \param bdev Block device to query.
 * \return Pointer to UUID.
 *
 * Not all bdevs will have a UUID; in this case, the returned UUID will be
 * the nil UUID (all bytes zero).
 */
const struct spdk_uuid *spdk_bdev_get_uuid(const struct spdk_bdev *bdev);

/**
 * Obtain an I/O channel for the block device opened by the specified
 * descriptor. I/O channels are bound to threads, so the resulting I/O
+8 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "spdk/queue.h"
#include "spdk/scsi_spec.h"
#include "spdk/io_channel.h"
#include "spdk/uuid.h"

/** \page block_backend_modules Block Device Backend Modules
 *
@@ -220,6 +221,13 @@ struct spdk_bdev {
	 */
	uint32_t optimal_io_boundary;

	/**
	 * UUID for this bdev.
	 *
	 * Fill with zeroes if no uuid is available.
	 */
	struct spdk_uuid uuid;

	/**
	 * Pointer to the bdev module that registered this bdev.
	 */
+6 −0
Original line number Diff line number Diff line
@@ -1192,6 +1192,12 @@ spdk_bdev_has_write_cache(const struct spdk_bdev *bdev)
	return bdev->write_cache;
}

const struct spdk_uuid *
spdk_bdev_get_uuid(const struct spdk_bdev *bdev)
{
	return &bdev->uuid;
}

int
spdk_bdev_notify_blockcnt_change(struct spdk_bdev *bdev, uint64_t size)
{
+1 −0
Original line number Diff line number Diff line
@@ -396,6 +396,7 @@ struct spdk_bdev *create_malloc_disk(const char *name, uint64_t num_blocks, uint
	mdisk->disk.write_cache = 1;
	mdisk->disk.blocklen = block_size;
	mdisk->disk.blockcnt = num_blocks;
	spdk_uuid_generate(&mdisk->disk.uuid);

	mdisk->disk.ctxt = mdisk;
	mdisk->disk.fn_table = &malloc_fn_table;
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ create_null_bdev(const char *name, uint64_t num_blocks, uint32_t block_size)
	bdev->bdev.write_cache = 0;
	bdev->bdev.blocklen = block_size;
	bdev->bdev.blockcnt = num_blocks;
	spdk_uuid_generate(&bdev->bdev.uuid);

	bdev->bdev.ctxt = bdev;
	bdev->bdev.fn_table = &null_fn_table;
Loading