module/raid: show base bdev details in json

Change-Id: I0da3e91e7736bc651e284f68238ace864def87b2
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
This commit is contained in:
Artur Paszkiewicz 2022-12-09 14:42:53 +01:00 committed by David Ko
parent e61c1c51be
commit 432d1a99cc
4 changed files with 43 additions and 8 deletions

View File

@ -10046,8 +10046,20 @@ Example response:
"num_base_bdevs": 2, "num_base_bdevs": 2,
"num_base_bdevs_discovered": 2, "num_base_bdevs_discovered": 2,
"base_bdevs_list": [ "base_bdevs_list": [
"malloc0", {
"malloc1" "name": "malloc0",
"uuid": "d2788884-5b3e-4fd7-87ff-6c78177e14ab",
"is_configured": true,
"data_offset": 256,
"data_size": 261888
},
{
"name": "malloc1",
"uuid": "a81bb1f8-5865-488a-8758-10152017e7d1",
"is_configured": true,
"data_offset": 256,
"data_size": 261888
}
] ]
}, },
{ {
@ -10059,8 +10071,20 @@ Example response:
"num_base_bdevs": 2, "num_base_bdevs": 2,
"num_base_bdevs_discovered": 1, "num_base_bdevs_discovered": 1,
"base_bdevs_list": [ "base_bdevs_list": [
"malloc2", {
null "name": "malloc2",
"uuid": "f60c20e1-3439-4f89-ae55-965a70333f86",
"is_configured": true,
"data_offset": 256,
"data_size": 261888
}
{
"name": "malloc3",
"uuid": "00000000-0000-0000-0000-000000000000",
"is_configured": false,
"data_offset": 0,
"data_size": 0
}
] ]
} }
] ]

View File

@ -629,6 +629,7 @@ void
raid_bdev_write_info_json(struct raid_bdev *raid_bdev, struct spdk_json_write_ctx *w) raid_bdev_write_info_json(struct raid_bdev *raid_bdev, struct spdk_json_write_ctx *w)
{ {
struct raid_base_bdev_info *base_info; struct raid_base_bdev_info *base_info;
char uuid_str[SPDK_UUID_STRING_LEN];
assert(raid_bdev != NULL); assert(raid_bdev != NULL);
assert(spdk_get_thread() == spdk_thread_get_app_thread()); assert(spdk_get_thread() == spdk_thread_get_app_thread());
@ -642,11 +643,19 @@ raid_bdev_write_info_json(struct raid_bdev *raid_bdev, struct spdk_json_write_ct
spdk_json_write_name(w, "base_bdevs_list"); spdk_json_write_name(w, "base_bdevs_list");
spdk_json_write_array_begin(w); spdk_json_write_array_begin(w);
RAID_FOR_EACH_BASE_BDEV(raid_bdev, base_info) { RAID_FOR_EACH_BASE_BDEV(raid_bdev, base_info) {
if (base_info->bdev) { spdk_json_write_object_begin(w);
spdk_json_write_string(w, base_info->bdev->name); spdk_json_write_name(w, "name");
if (base_info->name) {
spdk_json_write_string(w, base_info->name);
} else { } else {
spdk_json_write_null(w); spdk_json_write_null(w);
} }
spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &base_info->uuid);
spdk_json_write_named_string(w, "uuid", uuid_str);
spdk_json_write_named_bool(w, "is_configured", base_info->is_configured);
spdk_json_write_named_uint64(w, "data_offset", base_info->data_offset);
spdk_json_write_named_uint64(w, "data_size", base_info->data_size);
spdk_json_write_object_end(w);
} }
spdk_json_write_array_end(w); spdk_json_write_array_end(w);
} }

View File

@ -160,14 +160,14 @@ function verify_raid_bdev_state() (
return 1 return 1
fi fi
num_base_bdevs=$(echo $raid_bdev_info | jq -r '.base_bdevs_list | length') num_base_bdevs=$(echo $raid_bdev_info | jq -r '[.base_bdevs_list[]] | length')
tmp=$(echo $raid_bdev_info | jq -r '.num_base_bdevs') tmp=$(echo $raid_bdev_info | jq -r '.num_base_bdevs')
if [ "$num_base_bdevs" != "$tmp" ]; then if [ "$num_base_bdevs" != "$tmp" ]; then
echo "incorrect num_base_bdevs: $tmp, expected: $num_base_bdevs" echo "incorrect num_base_bdevs: $tmp, expected: $num_base_bdevs"
return 1 return 1
fi fi
num_base_bdevs_discovered=$(echo $raid_bdev_info | jq -r '[.base_bdevs_list[] | strings] | length') num_base_bdevs_discovered=$(echo $raid_bdev_info | jq -r '[.base_bdevs_list[] | select(.is_configured)] | length')
tmp=$(echo $raid_bdev_info | jq -r '.num_base_bdevs_discovered') tmp=$(echo $raid_bdev_info | jq -r '.num_base_bdevs_discovered')
if [ "$num_base_bdevs_discovered" != "$tmp" ]; then if [ "$num_base_bdevs_discovered" != "$tmp" ]; then
echo "incorrect num_base_bdevs_discovered: $tmp, expected: $num_base_bdevs_discovered" echo "incorrect num_base_bdevs_discovered: $tmp, expected: $num_base_bdevs_discovered"

View File

@ -113,6 +113,8 @@ DEFINE_STUB(spdk_json_write_named_array_begin, int, (struct spdk_json_write_ctx
const char *name), 0); const char *name), 0);
DEFINE_STUB(spdk_json_write_bool, int, (struct spdk_json_write_ctx *w, bool val), 0); DEFINE_STUB(spdk_json_write_bool, int, (struct spdk_json_write_ctx *w, bool val), 0);
DEFINE_STUB(spdk_json_write_null, int, (struct spdk_json_write_ctx *w), 0); DEFINE_STUB(spdk_json_write_null, int, (struct spdk_json_write_ctx *w), 0);
DEFINE_STUB(spdk_json_write_named_uint64, int, (struct spdk_json_write_ctx *w, const char *name,
uint64_t val), 0);
DEFINE_STUB(spdk_strerror, const char *, (int errnum), NULL); DEFINE_STUB(spdk_strerror, const char *, (int errnum), NULL);
DEFINE_STUB(spdk_bdev_queue_io_wait, int, (struct spdk_bdev *bdev, struct spdk_io_channel *ch, DEFINE_STUB(spdk_bdev_queue_io_wait, int, (struct spdk_bdev *bdev, struct spdk_io_channel *ch,
struct spdk_bdev_io_wait_entry *entry), 0); struct spdk_bdev_io_wait_entry *entry), 0);