From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org
Cc: dwagner@suse.de, hare@suse.de, kbusch@kernel.org, gjoyce@ibm.com
Subject: [PATCHv2 1/4] nvme: support <device> option in show-topology command
Date: Tue, 12 Aug 2025 18:26:02 +0530 [thread overview]
Message-ID: <20250812125614.164445-2-nilay@linux.ibm.com> (raw)
In-Reply-To: <20250812125614.164445-1-nilay@linux.ibm.com>
Although the help text for the nvme show-topology command indicates
support for a <device> option, this option has no effect in practice
— specifying an NVMe device name does not filter the output.
This commit adds proper support for the <device> option, enabling users
to filter the topology output based on the specified NVMe device.
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
nvme-print-stdout.c | 9 +++++++++
nvme.c | 17 ++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c
index c597b608..eb56349a 100644
--- a/nvme-print-stdout.c
+++ b/nvme-print-stdout.c
@@ -5683,6 +5683,15 @@ static void stdout_simple_topology(nvme_root_t r,
nvme_for_each_host(r, h) {
nvme_for_each_subsystem(h, s) {
+ bool no_ctrl = true;
+ nvme_ctrl_t c;
+
+ nvme_subsystem_for_each_ctrl(s, c)
+ no_ctrl = false;
+
+ if (no_ctrl)
+ continue;
+
if (!first)
printf("\n");
first = false;
diff --git a/nvme.c b/nvme.c
index 27dac37b..c6779cf4 100644
--- a/nvme.c
+++ b/nvme.c
@@ -10155,6 +10155,8 @@ static int show_topology_cmd(int argc, char **argv, struct command *command, str
const char *ranking = "Ranking order: namespace|ctrl";
nvme_print_flags_t flags;
_cleanup_nvme_root_ nvme_root_t r = NULL;
+ char *devname = NULL;
+ nvme_scan_filter_t filter = NULL;
enum nvme_cli_topo_ranking rank;
int err;
@@ -10197,7 +10199,20 @@ static int show_topology_cmd(int argc, char **argv, struct command *command, str
return -errno;
}
- err = nvme_scan_topology(r, NULL, NULL);
+ if (optind < argc)
+ devname = basename(argv[optind++]);
+
+ if (devname) {
+ int subsys_id, nsid;
+
+ if (sscanf(devname, "nvme%dn%d", &subsys_id, &nsid) != 2) {
+ nvme_show_error("Invalid device name %s\n", devname);
+ return -EINVAL;
+ }
+ filter = nvme_match_device_filter;
+ }
+
+ err = nvme_scan_topology(r, filter, (void *)devname);
if (err < 0) {
nvme_show_error("Failed to scan topology: %s", nvme_strerror(errno));
return err;
--
2.50.1
next prev parent reply other threads:[~2025-08-12 17:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 12:56 [PATCHv2 0/4] nvme-cli: enhance the visibility of multipath using show-topology command Nilay Shroff
2025-08-12 12:56 ` Nilay Shroff [this message]
2025-08-18 7:12 ` [PATCHv2 1/4] nvme: support <device> option in " Hannes Reinecke
2025-08-19 4:43 ` Nilay Shroff
2025-08-19 6:11 ` Hannes Reinecke
2025-08-12 12:56 ` [PATCHv2 2/4] nvme: extend show-topology command to add support for multipath Nilay Shroff
2025-08-18 7:22 ` Hannes Reinecke
2025-08-19 4:49 ` Nilay Shroff
2025-08-19 6:15 ` Hannes Reinecke
2025-08-19 10:31 ` Nilay Shroff
2025-08-19 11:05 ` Hannes Reinecke
2025-08-19 11:30 ` Nilay Shroff
2025-08-20 8:17 ` Daniel Wagner
2025-08-20 8:30 ` Hannes Reinecke
2025-08-20 11:59 ` Nilay Shroff
2025-09-01 9:21 ` Nilay Shroff
2025-09-01 16:36 ` Daniel Wagner
2025-09-02 6:26 ` Hannes Reinecke
2025-09-03 4:22 ` Nilay Shroff
2025-09-03 7:24 ` Daniel Wagner
2025-09-03 12:19 ` Nilay Shroff
2025-08-12 12:56 ` [PATCHv2 3/4] nvme: add common APIs for printing tabular format output Nilay Shroff
2025-08-18 7:27 ` Hannes Reinecke
2025-08-19 8:56 ` Nilay Shroff
2025-08-20 8:23 ` Daniel Wagner
2025-08-12 12:56 ` [PATCHv2 4/4] nvme: add support for printing show-topology in tabular form Nilay Shroff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250812125614.164445-2-nilay@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=dwagner@suse.de \
--cc=gjoyce@ibm.com \
--cc=hare@suse.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.