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

module/raid: show raid_bdev details in bdev_raid_get_bdevs rpc



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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
parent 95fd6cb4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ names with this option to restrict allowed RPCs to only that list.

Added spdk_rpc_set_allowlist to restrict allowed RPCs to the specified list.

Changed `bdev_raid_get_bdevs` RPC output format to include raid_bdev details.

### bdevperf

Promoted the application to example to match similar programs: fio_plugin and perf.
+25 −2
Original line number Diff line number Diff line
@@ -9496,7 +9496,7 @@ Example response:

### bdev_raid_get_bdevs {#rpc_bdev_raid_get_bdevs}

This is used to list all the raid bdev names based on the input category requested. Category should be one
This is used to list all the raid bdev details based on the input category requested. Category should be one
of 'all', 'online', 'configuring' or 'offline'. 'all' means all the raid bdevs whether they are online or
configuring or offline. 'online' is the raid bdev which is registered with bdev layer. 'configuring' is
the raid bdev which does not have full configuration discovered yet. 'offline' is the raid bdev which is
@@ -9531,7 +9531,30 @@ Example response:
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    "Raid0"
    {
      "name": "RaidBdev0",
      "strip_size_kb": 128,
      "state": "online",
      "raid_level": "raid0",
      "num_base_bdevs": 2,
      "num_base_bdevs_discovered": 2,
      "base_bdevs_list": [
        "malloc0",
        "malloc1"
      ]
    },
    {
      "name": "RaidBdev1",
      "strip_size_kb": 128,
      "state": "configuring",
      "raid_level": "raid0",
      "num_base_bdevs": 2,
      "num_base_bdevs_discovered": 1,
      "base_bdevs_list": [
        "malloc2",
        null
      ]
    }
  ]
}
~~~
+24 −16
Original line number Diff line number Diff line
@@ -604,27 +604,13 @@ raid_bdev_get_io_channel(void *ctxt)
	return spdk_get_io_channel(raid_bdev);
}

/*
 * brief:
 * raid_bdev_dump_info_json is the function table pointer for raid bdev
 * params:
 * ctx - pointer to raid_bdev
 * w - pointer to json context
 * returns:
 * 0 - success
 * non zero - failure
 */
static int
raid_bdev_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
void
raid_bdev_write_info_json(struct raid_bdev *raid_bdev, struct spdk_json_write_ctx *w)
{
	struct raid_bdev *raid_bdev = ctx;
	struct raid_base_bdev_info *base_info;

	SPDK_DEBUGLOG(bdev_raid, "raid_bdev_dump_config_json\n");
	assert(raid_bdev != NULL);

	/* Dump the raid bdev configuration related information */
	spdk_json_write_named_object_begin(w, "raid");
	spdk_json_write_named_uint32(w, "strip_size_kb", raid_bdev->strip_size_kb);
	spdk_json_write_named_string(w, "state", raid_bdev_state_to_str(raid_bdev->state));
	spdk_json_write_named_string(w, "raid_level", raid_bdev_level_to_str(raid_bdev->level));
@@ -640,6 +626,28 @@ raid_bdev_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
		}
	}
	spdk_json_write_array_end(w);
}

/*
 * brief:
 * raid_bdev_dump_info_json is the function table pointer for raid bdev
 * params:
 * ctx - pointer to raid_bdev
 * w - pointer to json context
 * returns:
 * 0 - success
 * non zero - failure
 */
static int
raid_bdev_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
{
	struct raid_bdev *raid_bdev = ctx;

	SPDK_DEBUGLOG(bdev_raid, "raid_bdev_dump_config_json\n");

	/* Dump the raid bdev configuration related information */
	spdk_json_write_named_object_begin(w, "raid");
	raid_bdev_write_info_json(raid_bdev, w);
	spdk_json_write_object_end(w);

	return 0;
+1 −0
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ enum raid_level raid_bdev_str_to_level(const char *str);
const char *raid_bdev_level_to_str(enum raid_level level);
enum raid_bdev_state raid_bdev_str_to_state(const char *str);
const char *raid_bdev_state_to_str(enum raid_bdev_state state);
void raid_bdev_write_info_json(struct raid_bdev *raid_bdev, struct spdk_json_write_ctx *w);

/*
 * RAID module descriptor
+4 −1
Original line number Diff line number Diff line
@@ -87,7 +87,10 @@ rpc_bdev_raid_get_bdevs(struct spdk_jsonrpc_request *request,
	/* Get raid bdev list based on the category requested */
	TAILQ_FOREACH(raid_bdev, &g_raid_bdev_list, global_link) {
		if (raid_bdev->state == state || state == RAID_BDEV_STATE_MAX) {
			spdk_json_write_string(w, raid_bdev->bdev.name);
			spdk_json_write_object_begin(w);
			spdk_json_write_named_string(w, "name", raid_bdev->bdev.name);
			raid_bdev_write_info_json(raid_bdev, w);
			spdk_json_write_object_end(w);
		}
	}
	spdk_json_write_array_end(w);
Loading