Commit 95a367d6 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Konrad Sztyber
Browse files

util/uuid: add API to test/set null uuid



Refactor the code to use these new functions.

Change-Id: I21ee7e9a96f30fbd60106add5e8b071e86bf93c9
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16156


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 18ba317c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -83,6 +83,11 @@ New API `spdk_bdev_part_construct_ext` is added and allows the bdev's UUID to be
the existing worker and namespace association logic to access every namespace from each worker.
This replicates behavior of bdevperf application when `-C` option is provided.

### util

New APIs `spdk_uuid_is_null` and `spdk_uuid_set_null` were added to compare and
set UUID to NULL value.

## v23.01

### accel
+16 −0
Original line number Diff line number Diff line
@@ -86,6 +86,22 @@ int spdk_uuid_generate_sha1(struct spdk_uuid *uuid, struct spdk_uuid *ns_uuid, c
 */
void spdk_uuid_copy(struct spdk_uuid *dst, const struct spdk_uuid *src);

/**
 * Compare the UUID to the NULL value (all bits equal to zero).
 *
 * \param uuid The UUID to test.
 *
 * \return true if uuid is equal to the NULL value, false if not.
 */
bool spdk_uuid_is_null(const struct spdk_uuid *uuid);

/**
 * Set the value of UUID to the NULL value.
 *
 * \param uuid The UUID to set.
 */
void spdk_uuid_set_null(struct spdk_uuid *uuid);

#ifdef __cplusplus
}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -7399,7 +7399,7 @@ bdev_register(struct spdk_bdev *bdev)

	/* 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))) {
	if (spdk_uuid_is_null(&bdev->uuid)) {
		spdk_uuid_generate(&bdev->uuid);
	}

+2 −2
Original line number Diff line number Diff line
@@ -255,11 +255,11 @@ load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
	if (rc != 0 || value_len != SPDK_UUID_STRING_LEN || attr[SPDK_UUID_STRING_LEN - 1] != '\0' ||
	    spdk_uuid_parse(&lvol->uuid, attr) != 0) {
		SPDK_INFOLOG(lvol, "Missing or corrupt lvol uuid\n");
		memset(&lvol->uuid, 0, sizeof(lvol->uuid));
		spdk_uuid_set_null(&lvol->uuid);
	}
	spdk_uuid_fmt_lower(lvol->uuid_str, sizeof(lvol->uuid_str), &lvol->uuid);

	if (!spdk_mem_all_zero(&lvol->uuid, sizeof(lvol->uuid))) {
	if (!spdk_uuid_is_null(&lvol->uuid)) {
		snprintf(lvol->unique_id, sizeof(lvol->unique_id), "%s", lvol->uuid_str);
	} else {
		spdk_uuid_fmt_lower(lvol->unique_id, sizeof(lvol->unique_id), &lvol->lvol_store->uuid);
+1 −1
Original line number Diff line number Diff line
@@ -541,7 +541,7 @@ nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w,
			spdk_json_write_named_string_fmt(w, "eui64", "%016"PRIX64, from_be64(&ns_opts.eui64));
		}

		if (!spdk_mem_all_zero(&ns_opts.uuid, sizeof(ns_opts.uuid))) {
		if (!spdk_uuid_is_null(&ns_opts.uuid)) {
			spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &ns_opts.uuid);
			spdk_json_write_named_string(w, "uuid",  uuid_str);
		}
Loading