Commit 11dc297c authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Konrad Sztyber
Browse files

bdev: always generate UUIDs



Make sure UUID is present for every bdev, even ephemeral ones.
Furthermore, this change removes assumption that bdev UUID
may remain empty.

Change-Id: I924c1ba9dedfe88a05044bb1073f28085735b1c1
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17106


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 0cd5af71
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ struct spdk_bdev {
	/**
	 * UUID for this bdev.
	 *
	 * Fill with zeroes if no uuid is available.
	 * If not provided, it will be generated by bdev layer.
	 */
	struct spdk_uuid uuid;

+16 −15
Original line number Diff line number Diff line
@@ -7231,10 +7231,12 @@ bdev_register(struct spdk_bdev *bdev)
		return ret;
	}

	/* UUID has to be specified by the user or defined by bdev itself.
	 * Otherwise this field must remain empty, to indicate that this
	 * value cannot be depended upon. */
	if (!spdk_mem_all_zero(&bdev->uuid, sizeof(bdev->uuid))) {
	/* UUID may be specified by the user or defined by bdev itself.
	 * Otherwise it will be generated here, so this field will never be empty. */
	if (spdk_mem_all_zero(&bdev->uuid, sizeof(bdev->uuid))) {
		spdk_uuid_generate(&bdev->uuid);
	}

	/* Add the UUID alias only if it's different than the name */
	spdk_uuid_fmt_lower(uuid, sizeof(uuid), &bdev->uuid);
	if (strcmp(bdev->name, uuid) != 0) {
@@ -7247,7 +7249,6 @@ bdev_register(struct spdk_bdev *bdev)
			return ret;
		}
	}
	}

	if (spdk_bdev_get_buf_align(bdev) > 1) {
		if (bdev->split_on_optimal_io_boundary) {
+3 −6
Original line number Diff line number Diff line
@@ -663,6 +663,7 @@ rpc_dump_bdev_info(void *ctx, struct spdk_bdev *bdev)
	struct spdk_bdev_alias *tmp;
	uint64_t qos_limits[SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES];
	struct spdk_memory_domain **domains;
	char uuid_str[SPDK_UUID_STRING_LEN];
	int i, rc;

	spdk_json_write_object_begin(w);
@@ -683,12 +684,8 @@ rpc_dump_bdev_info(void *ctx, struct spdk_bdev *bdev)

	spdk_json_write_named_uint64(w, "num_blocks", spdk_bdev_get_num_blocks(bdev));

	if (!spdk_mem_all_zero(&bdev->uuid, sizeof(bdev->uuid))) {
		char uuid_str[SPDK_UUID_STRING_LEN];

	spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &bdev->uuid);
	spdk_json_write_named_string(w, "uuid", uuid_str);
	}

	if (spdk_bdev_get_md_size(bdev) != 0) {
		spdk_json_write_named_uint32(w, "md_size", spdk_bdev_get_md_size(bdev));
+4 −1
Original line number Diff line number Diff line
{
  "aliases": [],
  "aliases": [
    "$(UUID)"
  ],
  "assigned_rate_limits": {
    "r_mbytes_per_sec": $(N),
    "rw_ios_per_sec": $(N),
@@ -30,5 +32,6 @@
    "write": $(S),
    "write_zeroes": $(S)
  },
  "uuid": "$(UUID)",
  "zoned": false
}
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ o- bdevs .......................................................................
  o- null ............................................................................................................... [Bdevs: 0]
  o- nvme ............................................................................................................... [Bdevs: 0]
  o- raid_volume ........................................................................................................ [Bdevs: 1]
  | o- testraid $(S) [Size=16.0M, Not claimed]
  | o- testraid $(S) [$(UUID), Size=16.0M, Not claimed]
  o- rbd ................................................................................................................ [Bdevs: 0]
  o- split_disk ......................................................................................................... [Bdevs: 0]
  o- uring .............................................................................................................. [Bdevs: 0]
Loading