From c93589b846233939359e4e2616ffc4381a7ff84e Mon Sep 17 00:00:00 2001 From: tanlong <948985618@qq.com> Date: Sun, 7 Nov 2021 21:16:40 -0500 Subject: [PATCH] bdev/nvme:Print multiple namespace attributes of nvme bdev in bdev_get_bdevs Current code only print the last namespace of nvme bdev, fix the print way to show all the namespace. And this patch will be prepared for the next patch to show io path status for multipath, like: which one is the primary or the backup, and the old status and current status,etc. Signed-off-by: tanlong <948985618@qq.com> Change-Id: I4fca154df52c929b8d046198934db0e58586c378 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10140 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk Community-CI: Broadcom CI Community-CI: Mellanox Build Bot --- module/bdev/nvme/bdev_nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index cbdb07fdc..f4f319de1 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -1931,7 +1931,7 @@ nvme_namespace_info_json(struct spdk_json_write_ctx *w, trid = spdk_nvme_ctrlr_get_transport_id(ctrlr); vs = spdk_nvme_ctrlr_get_regs_vs(ctrlr); - spdk_json_write_named_object_begin(w, "nvme"); + spdk_json_write_object_begin(w); if (trid->trtype == SPDK_NVME_TRANSPORT_PCIE) { spdk_json_write_named_string(w, "pci_address", trid->traddr); @@ -2025,9 +2025,11 @@ bdev_nvme_dump_info_json(void *ctx, struct spdk_json_write_ctx *w) struct nvme_ns *nvme_ns; pthread_mutex_lock(&nvme_bdev->mutex); + spdk_json_write_named_array_begin(w, "nvme"); TAILQ_FOREACH(nvme_ns, &nvme_bdev->nvme_ns_list, tailq) { nvme_namespace_info_json(w, nvme_ns); } + spdk_json_write_array_end(w); pthread_mutex_unlock(&nvme_bdev->mutex); return 0;