From ef8047033825453bf41e23cc0b6526e5b2750a1f Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 21 Sep 2018 10:57:22 +0900 Subject: [PATCH] bdev/raid: Add .INI config dump Add dump the current configuration of raid bdevs to the specified file for .INI config file. .INI config file will be deprecated but this addition will be helpful for now. Change-Id: I35582ceaff18d81b066e3e63e0c8c22525ec6b9e Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/426299 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Hailiang Wang Reviewed-by: Pawel Wodkowski Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/bdev/raid/bdev_raid.c | 45 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index ce7a97db9..e29b0ae60 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -1097,6 +1097,49 @@ raid_bdev_get_ctx_size(void) return sizeof(struct raid_bdev_io); } +/* + * brief: + * raid_bdev_get_running_config is used to get the configuration options. + * + * params: + * fp - The pointer to a file that will be written to the configuration options. + * returns: + * none + */ +static void +raid_bdev_get_running_config(FILE *fp) +{ + struct raid_bdev *raid_bdev; + struct spdk_bdev *base; + int index = 1; + uint16_t i; + + TAILQ_FOREACH(raid_bdev, &g_spdk_raid_bdev_configured_list, state_link) { + fprintf(fp, + "\n" + "[RAID%d]\n" + " Name %s\n" + " StripSize %" PRIu32 "\n" + " NumDevices %hu\n" + " RaidLevel %hhu\n", + index, raid_bdev->bdev.name, raid_bdev->strip_size, + raid_bdev->num_base_bdevs, raid_bdev->raid_level); + fprintf(fp, + " Devices "); + for (i = 0; i < raid_bdev->num_base_bdevs; i++) { + base = raid_bdev->base_bdev_info[i].bdev; + if (base) { + fprintf(fp, + "%s ", + base->name); + } + } + fprintf(fp, + "\n"); + index++; + } +} + /* * brief: * raid_bdev_can_claim_bdev is the function to check if this base_bdev can be @@ -1143,7 +1186,7 @@ static struct spdk_bdev_module g_raid_if = { .module_fini = raid_bdev_exit, .get_ctx_size = raid_bdev_get_ctx_size, .examine_config = raid_bdev_examine, - .config_text = NULL, + .config_text = raid_bdev_get_running_config, .async_init = false, .async_fini = false, };