File 0003-nvme-print-Show-paths-from-the-first-namespace-only.patch of Package nvme-cli.26914

From: Daniel Wagner <dwagner@suse.de>
Date: Wed, 25 May 2022 17:33:08 +0200
Subject: nvme-print: Show paths from the first namespace only
Git-commit: 7435ed9ae6a66fa3f7f5d5164bc727c73aed6759
References: bsc#1200044 bsc#1199956 bsc#1199990

When listing the subsystem, show the path from the first namespace
only. Every namespace has the same paths for a subsystem. This avoids
listening the same controllers for each namespace.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 nvme-print.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/nvme-print.c b/nvme-print.c
index 1e4e4c8c88d5..0bc759f4a404 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -2376,22 +2376,23 @@ void nvme_show_supported_cap_config_log(
 static unsigned int nvme_show_subsystem_multipath(nvme_subsystem_t s)
 {
 	nvme_ns_t n;
+	nvme_path_t p;
 	unsigned int i = 0;
 
-	nvme_subsystem_for_each_ns(s, n) {
-		nvme_path_t p;
+	n = nvme_subsystem_first_ns(s);
+	if (!n)
+		return 0;
 
-		nvme_namespace_for_each_path(n, p) {
-			nvme_ctrl_t c = nvme_path_get_ctrl(p);
+	nvme_namespace_for_each_path(n, p) {
+		nvme_ctrl_t c = nvme_path_get_ctrl(p);
 
-			printf(" +- %s %s %s %s %s\n",
-			       nvme_ctrl_get_name(c),
-			       nvme_ctrl_get_transport(c),
-			       nvme_ctrl_get_address(c),
-			       nvme_ctrl_get_state(c),
-			       nvme_path_get_ana_state(p));
-			i++;
-		}
+		printf(" +- %s %s %s %s %s\n",
+		       nvme_ctrl_get_name(c),
+		       nvme_ctrl_get_transport(c),
+		       nvme_ctrl_get_address(c),
+		       nvme_ctrl_get_state(c),
+		       nvme_path_get_ana_state(p));
+		i++;
 	}
 
 	return i;
-- 
2.36.1

openSUSE Build Service is sponsored by