From 89bdba564a2906eb3a6f1f254cf5e7fe60472603 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 29 Aug 2019 09:45:06 -0700 Subject: [PATCH] nvme/identify: clarify total and active namespaces As SSDs with namespace management become more prevalant, improve the identify utility to clarify things like the total number of namespaces, and that data is printed out for active namespaces only. While here, change an active namespace check to an assert. The print_namespace() function is only called for active namespaces, so the check and print was a bit confusing since it is never seen with SSDs with inactive namespaces. Signed-off-by: Jim Harris Change-Id: Ib21772579b94c5bcd1c518adb9d3341f4bf824f6 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466818 Reviewed-by: Broadcom SPDK FC-NVMe CI Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- examples/nvme/identify/identify.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index 38ec529f1..40beb758e 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -680,10 +680,8 @@ print_namespace(struct spdk_nvme_ns *ns) printf("\n"); } - if (!spdk_nvme_ns_is_active(ns)) { - printf("Inactive namespace ID\n\n"); - return; - } + /* This function is only called for active namespaces. */ + assert(spdk_nvme_ns_is_active(ns)); printf("Deallocate: %s\n", (flags & SPDK_NVME_NS_DEALLOCATE_SUPPORTED) ? "Supported" : "Not Supported"); @@ -964,6 +962,7 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport } else { printf("%" PRIu64 "\n", (uint64_t)1 << (12 + cap.bits.mpsmin + cdata->mdts)); } + printf("Max Number of Namespaces: %d\n", cdata->nn); if (features[SPDK_NVME_FEAT_ERROR_RECOVERY].valid) { unsigned tler = features[SPDK_NVME_FEAT_ERROR_RECOVERY].result & 0xFFFF; printf("Error Recovery Timeout: "); @@ -1561,6 +1560,8 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport printf("\n"); } + printf("Active Namespaces\n"); + printf("=================\n"); for (nsid = spdk_nvme_ctrlr_get_first_active_ns(ctrlr); nsid != 0; nsid = spdk_nvme_ctrlr_get_next_active_ns(ctrlr, nsid)) { print_namespace(spdk_nvme_ctrlr_get_ns(ctrlr, nsid));