Commit 96aff3c9 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Jim Harris
Browse files

raid: fix some issues in raid_bdev_write_config_json()



Don't write out strip size if it is not set, also skip the superblock
field because its value is always false here.

Don't just skip printing removed base bdevs because recreating a raid
bdev from such config would result in a raid with a smaller number of
base bdevs and different layout in case of raid5f. Creating a raid bdev
with missing base bdevs is currently not possible, so make up a bdev
name for a missing slot that will prevent from actually activating the
raid.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent f9cccaa8
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1155,14 +1155,20 @@ raid_bdev_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *
	spdk_json_write_named_object_begin(w, "params");
	spdk_json_write_named_string(w, "name", bdev->name);
	spdk_json_write_named_uuid(w, "uuid", &raid_bdev->bdev.uuid);
	if (raid_bdev->strip_size_kb != 0) {
		spdk_json_write_named_uint32(w, "strip_size_kb", raid_bdev->strip_size_kb);
	}
	spdk_json_write_named_string(w, "raid_level", raid_bdev_level_to_str(raid_bdev->level));
	spdk_json_write_named_bool(w, "superblock", raid_bdev->superblock_enabled);

	spdk_json_write_named_array_begin(w, "base_bdevs");
	RAID_FOR_EACH_BASE_BDEV(raid_bdev, base_info) {
		if (base_info->desc) {
			spdk_json_write_string(w, spdk_bdev_desc_get_bdev(base_info->desc)->name);
		if (base_info->name) {
			spdk_json_write_string(w, base_info->name);
		} else {
			char str[32];

			snprintf(str, sizeof(str), "removed_base_bdev_%u", raid_bdev_base_bdev_slot(base_info));
			spdk_json_write_string(w, str);
		}
	}
	spdk_json_write_array_end(w);