Skip to contentSkip to conversation

nvme: Introduce new 'list-subsys' command

PATCH New Johannes Thumshirn 2 participants 2 messages Dec 13, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme: Introduce new 'list-subsys' command

Introduce a 'nvme list-subsys' command to give basic information about connected NVMe subsystems.

Here's an example output of a host connected to two subsystems on the target with two paths to each subsystem:
root at host# nvme list-subsys
nvme-subsys0 - NQN=nvmf-test
\

 +- nvme0 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
 +- nvme1 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
nvme-subsys1 - NQN=nvmf-test2
\
 +- nvme2 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
 +- nvme3 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
Signed-off-by Johannes Thumshirn <jthumshirn at suse.de>

---
Changes to v1:
- Fix manpage build
- Check return of asprintf()

---
 Documentation/nvme-list-subsys.txt  |  81 +++++++++
 completions/bash-nvme-completion.sh |   2 +-
 nvme-builtin.h                      |   1 +
 nvme-print.c                        |  49 ++++++
 nvme-print.h                        |   1 +
 nvme.c                              | 340 ++++++++++++++++++++++++++++++++++++
 nvme.h                              |  13 ++
 7 files changed, 486 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/nvme-list-subsys.txt
Documentation/nvme-list-subsys.txt new file +81 -0
new file mode 100644
index 000000000000..c7de7efba654
@@ -0,0 +1,81 @@
+nvme-list-subsys(1)
+===================
+
+NAME
+----
+nvme-list-subsys - List all NVMe subsystems
+
+SYNOPSIS
+--------
+[verse]
+'nvme list-subsys' [-o <fmt> | --output-format=<fmt>]
+
+DESCRIPTION
+-----------
+Scan the sysfs tree for NVM Express subsystems and return the controllers
+for those subsystems as well as some pertinent information about them.
+
+OPTIONS
+-------
+-o <format>::
+--output-format=<format>::
+	Set the reporting format to 'normal' or 'json'. Only one output
+	format can be used at a time.
+
+EXAMPLES
+--------
+root at host# nvme list-subsys
+nvme-subsys0 - NQN=nvmf-test
+\
+ +- nvme0 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
+ +- nvme1 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
+nvme-subsys1 - NQN=nvmf-test2
+\
+ +- nvme2 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
+ +- nvme3 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
+
+root at host# nvme list-subsys -o json
+{
+  "Subsystems" : [
+    {
+      "Name" : "nvme-subsys0",
+      "NQN" : "nvmf-test"
+    },
+    {
+      "Paths" : [
+        {
+          "Name" : "nvme0",
+          "Transport" : "rdma",
+          "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1"
+        },
+        {
+          "Name" : "nvme1",
+          "Transport" : "rdma",
+          "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2"
+        }
+      ]
+    },
+    {
+      "Name" : "nvme-subsys1",
+      "NQN" : "nvmf-test2"
+    },
+    {
+      "Paths" : [
+        {
+          "Name" : "nvme2",
+          "Transport" : "rdma",
+          "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2"
+        },
+        {
+          "Name" : "nvme3",
+          "Transport" : "rdma",
+          "Address" : "traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1"
+        }
+      ]
+    }
+  ]
+}
+
+NVME
+----
+Part of the nvme-user suite
completions/bash-nvme-completion.sh +1 -1
index da16f0e2b145..5abc30e8086a 100644
@@ -11,7 +11,7 @@ _cmds="list id-ctrl id-ns list-ns create-ns delete-ns \
 	resv-report dsm flush compare read write write-zeroes \
 	write-uncor reset subsystem-reset show-regs discover \
 	connect-all connect disconnect version help \
-	intel lnvm memblaze"
+	intel lnvm memblaze list-subsys"
 
 nvme_list_opts () {
         local opts=""
nvme-builtin.h +1 -0
index 1a5ab361e9f3..23e8dd9ebcda 100644
@@ -56,6 +56,7 @@ COMMAND_LIST(
 	ENTRY("gen-hostnqn", "Generate NVMeoF host NQN", gen_hostnqn_cmd)
 	ENTRY("dir-receive", "Submit a Directive Receive command, return results", dir_receive)
 	ENTRY("dir-send", "Submit a Directive Send command, return results", dir_send)
+	ENTRY("list-subsys", "List nvme subsystems", list_subsys)
 );
 
 #endif
nvme-print.c +49 -0

55 lines not on this page · raw message

nvme-print.h +1 -0
index d110b980c461..64bdb7edcbeb 100644
@@ -43,6 +43,7 @@ void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char
 void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname);
 void json_print_list_items(struct list_item *items, unsigned amnt);
 void json_nvme_id_ns_descs(void *data);
+void json_print_nvme_subsystem_list(struct subsys_list_item *slist, int n);
 
 
 #endif
nvme.c +340 -0

346 lines not on this page · raw message

nvme.h +13 -0
index ec68f1748128..b134be1e251c 100644
@@ -117,6 +117,19 @@ struct list_item {
 	unsigned            block;
 };
 
+struct ctrl_list_item {
+	char *name;
+	char *address;
+	char *transport;
+};
+
+struct subsys_list_item {
+	char *name;
+	char *subsysnqn;
+	int nctrls;
+	struct ctrl_list_item *ctrls;
+};
+
 enum {
 	NORMAL,
 	JSON,
Signature · 1 line
2.13.6
#1 lore raw

PATCH v2 1/1 nvme: Introduce new 'list-subsys' command

Quoted 8 lines · Johannes Thumshirn

Introduce a 'nvme list-subsys' command to give basic information about connected NVMe subsystems.

Here's an example output of a host connected to two subsystems on the target with two paths to each subsystem:
root at host# nvme list-subsys
nvme-subsys0 - NQN=nvmf-test
\

Quoted 8 lines
 +- nvme0 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
 +- nvme1 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
nvme-subsys1 - NQN=nvmf-test2
\
 +- nvme2 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.2
 +- nvme3 rdma traddr=1.1.1.3 trsvcid=4420 host_traddr=1.1.1.1
Signed-off-by Johannes Thumshirn <jthumshirn at suse.de>

Thanks, this looks good to me! Applied.