From: Daniel Wagner <dwagner@suse.de>
Date: Wed, 26 Jul 2023 13:46:55 +0000 (+0200)
Subject: nvme-print-stdout: Do not show non reachable ns in namespace topology
X-Git-Tag: v2.6~65
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=da1e6a4be9f957c28bcff56f1b691fe25d4e6657;p=users%2Fsagi%2Fnvme-cli.git

nvme-print-stdout: Do not show non reachable ns in namespace topology

If the host is connected to the target with two different hostnqn we can
have the situation where a namespace is only reachable via one ctrl and
a second namespace only by a different controller. Thus we should only
show a namespace in the topology if there is a path.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---

diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c
index 566571df..975ac628 100644
--- a/nvme-print-stdout.c
+++ b/nvme-print-stdout.c
@@ -4764,6 +4764,9 @@ static void stdout_subsystem_topology_multipath(nvme_subsystem_t s,
 
 	if (ranking == NVME_CLI_TOPO_NAMESPACE) {
 		nvme_subsystem_for_each_ns(s, n) {
+			if (!nvme_namespace_first_path(n))
+				continue;
+
 			printf(" +- ns %d\n", nvme_ns_get_nsid(n));
 			printf(" \\\n");