Commit 8cffbe01 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

rpc: use spdk_json_write_uuid() to dump UUIDs



While here, remove some of the empty lines between spdk_json_write*
calls, as they only made the code less readable.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I22909de1a04cd24322534971daf3128776c36855
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20473


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 5d91b074
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -651,7 +651,6 @@ 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);
@@ -667,13 +666,9 @@ rpc_dump_bdev_info(void *ctx, struct spdk_bdev *bdev)
	spdk_json_write_array_end(w);

	spdk_json_write_named_string(w, "product_name", spdk_bdev_get_product_name(bdev));

	spdk_json_write_named_uint32(w, "block_size", spdk_bdev_get_block_size(bdev));

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

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

	if (spdk_bdev_get_md_size(bdev) != 0) {
		spdk_json_write_named_uint32(w, "md_size", spdk_bdev_get_md_size(bdev));
+2 −9
Original line number Diff line number Diff line
@@ -256,10 +256,7 @@ dump_nvmf_subsystem(struct spdk_json_write_ctx *w, struct spdk_nvmf_subsystem *s
			}

			if (!spdk_uuid_is_null(&ns_opts.uuid)) {
				char uuid_str[SPDK_UUID_STRING_LEN];

				spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &ns_opts.uuid);
				spdk_json_write_named_string(w, "uuid", uuid_str);
				spdk_json_write_named_uuid(w, "uuid", &ns_opts.uuid);
			}

			if (nvmf_subsystem_get_ana_reporting(subsystem)) {
@@ -2439,17 +2436,13 @@ SPDK_RPC_REGISTER("nvmf_get_stats", rpc_nvmf_get_stats, SPDK_RPC_RUNTIME)
static void
dump_nvmf_ctrlr(struct spdk_json_write_ctx *w, struct spdk_nvmf_ctrlr *ctrlr)
{
	char uuid_str[SPDK_UUID_STRING_LEN] = {};
	uint32_t count;

	spdk_json_write_object_begin(w);

	spdk_json_write_named_uint32(w, "cntlid", ctrlr->cntlid);

	spdk_json_write_named_string(w, "hostnqn", ctrlr->hostnqn);

	spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &ctrlr->hostid);
	spdk_json_write_named_string(w, "hostid", uuid_str);
	spdk_json_write_named_uuid(w, "hostid", &ctrlr->hostid);

	count = spdk_bit_array_count_set(ctrlr->qpair_mask);
	spdk_json_write_named_uint32(w, "num_io_qpairs", count);
+1 −3
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ static void
rpc_bdev_ftl_create_cb(const struct ftl_bdev_info *bdev_info, void *ctx, int status)
{
	struct spdk_jsonrpc_request *request = ctx;
	char bdev_uuid[SPDK_UUID_STRING_LEN];
	struct spdk_json_write_ctx *w;

	if (status) {
@@ -67,10 +66,9 @@ rpc_bdev_ftl_create_cb(const struct ftl_bdev_info *bdev_info, void *ctx, int sta
	}

	w = spdk_jsonrpc_begin_result(request);
	spdk_uuid_fmt_lower(bdev_uuid, sizeof(bdev_uuid), &bdev_info->uuid);
	spdk_json_write_object_begin(w);
	spdk_json_write_named_string(w, "name", bdev_info->name);
	spdk_json_write_named_string(w, "uuid", bdev_uuid);
	spdk_json_write_named_uuid(w, "uuid", &bdev_info->uuid);
	spdk_json_write_object_end(w);
	spdk_jsonrpc_end_result(request, w);
}
+3 −16
Original line number Diff line number Diff line
@@ -71,17 +71,14 @@ static void
rpc_lvol_store_construct_cb(void *cb_arg, struct spdk_lvol_store *lvol_store, int lvserrno)
{
	struct spdk_json_write_ctx *w;
	char lvol_store_uuid[SPDK_UUID_STRING_LEN];
	struct spdk_jsonrpc_request *request = cb_arg;

	if (lvserrno != 0) {
		goto invalid;
	}

	spdk_uuid_fmt_lower(lvol_store_uuid, sizeof(lvol_store_uuid), &lvol_store->uuid);

	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_string(w, lvol_store_uuid);
	spdk_json_write_uuid(w, &lvol_store->uuid);
	spdk_jsonrpc_end_result(request, w);
	return;

@@ -1092,26 +1089,18 @@ rpc_dump_lvol_store_info(struct spdk_json_write_ctx *w, struct lvol_store_bdev *
{
	struct spdk_blob_store *bs;
	uint64_t cluster_size;
	char uuid[SPDK_UUID_STRING_LEN];

	bs = lvs_bdev->lvs->blobstore;
	cluster_size = spdk_bs_get_cluster_size(bs);

	spdk_json_write_object_begin(w);

	spdk_uuid_fmt_lower(uuid, sizeof(uuid), &lvs_bdev->lvs->uuid);
	spdk_json_write_named_string(w, "uuid", uuid);

	spdk_json_write_named_uuid(w, "uuid", &lvs_bdev->lvs->uuid);
	spdk_json_write_named_string(w, "name", lvs_bdev->lvs->name);

	spdk_json_write_named_string(w, "base_bdev", spdk_bdev_get_name(lvs_bdev->bdev));

	spdk_json_write_named_uint64(w, "total_data_clusters", spdk_bs_total_data_cluster_count(bs));

	spdk_json_write_named_uint64(w, "free_clusters", spdk_bs_free_cluster_count(bs));

	spdk_json_write_named_uint64(w, "block_size", spdk_bs_get_io_unit_size(bs));

	spdk_json_write_named_uint64(w, "cluster_size", cluster_size);

	spdk_json_write_object_end(w);
@@ -1193,7 +1182,6 @@ static void
rpc_dump_lvol(struct spdk_json_write_ctx *w, struct spdk_lvol *lvol)
{
	struct spdk_lvol_store *lvs = lvol->lvol_store;
	char uuid[SPDK_UUID_STRING_LEN];

	spdk_json_write_object_begin(w);

@@ -1208,8 +1196,7 @@ rpc_dump_lvol(struct spdk_json_write_ctx *w, struct spdk_lvol *lvol)

	spdk_json_write_named_object_begin(w, "lvs");
	spdk_json_write_named_string(w, "name", lvs->name);
	spdk_uuid_fmt_lower(uuid, sizeof(uuid), &lvs->uuid);
	spdk_json_write_named_string(w, "uuid", uuid);
	spdk_json_write_named_uuid(w, "uuid", &lvs->uuid);
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);