bdev: All bdevs now have a UUID.

For devices that don't have a UUID, the UUID is generated at
registration time. That means that some devices will not have the same
UUID from run to run, but this seems no worse than having no UUID at
all.

Change-Id: Icf6b8517ffcffabafa2b73176dc03d896d0017fe
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459604
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2019-06-27 02:44:24 -07:00 committed by Changpeng Liu
parent 5317a9f795
commit 75b4f332f4
4 changed files with 11 additions and 4 deletions

View File

@ -411,8 +411,8 @@ bool spdk_bdev_has_write_cache(const struct spdk_bdev *bdev);
* \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).
* All bdevs will have a UUID, but not all UUIDs will be persistent across
* application runs.
*/
const struct spdk_uuid *spdk_bdev_get_uuid(const struct spdk_bdev *bdev);

View File

@ -293,7 +293,8 @@ struct spdk_bdev {
/**
* UUID for this bdev.
*
* Fill with zeroes if no uuid is available.
* Fill with zeroes if no uuid is available. The bdev layer
* will automatically populate this if necessary.
*/
struct spdk_uuid uuid;

View File

@ -4022,6 +4022,11 @@ spdk_bdev_init(struct spdk_bdev *bdev)
bdev->internal.qd_poller = NULL;
bdev->internal.qos = NULL;
/* If the user didn't specify a uuid, generate one. */
if (spdk_mem_all_zero(&bdev->uuid, sizeof(bdev->uuid))) {
spdk_uuid_generate(&bdev->uuid);
}
if (spdk_bdev_get_buf_align(bdev) > 1) {
if (bdev->split_on_optimal_io_boundary) {
bdev->optimal_io_boundary = spdk_min(bdev->optimal_io_boundary,

View File

@ -26,5 +26,6 @@
"unmap": $(S),
"write": $(S),
"write_zeroes": $(S)
}
},
"uuid": "$(S)"
}