Skip to contentSkip to conversation

nvme: add support for non shared namespaces

PATCH In review Max Gurtovoy 2 participants 2 messages Aug 26, 2020 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: add support for non shared namespaces

Currently, nvme-cli assume that all the namespaces in an NVM subsystem are shared between all the controllers. There is an option to create both shared and non-shared namespaces among the controllers in the same NVM subsystem. For example, in SR-IOV environment, one can attach 1 namespace to each controller that will be private and also 1 namespace that will be shared among the secondary controllers only. In this case, the output of "nvme list -v" will be wrong:

NVM Express Subsystems

Subsystem Subsystem-NQN Controllers
---------------- ------------------------------------------------------------------------------------------------ ----------------
nvme-subsys5 nqn.1994-11.com.samsung:nvme:PM1733:2.5-inch:S4YNNE0N700448 nvme18, nvme19, nvme20, nvme21, nvme5

NVM Express Controllers

Device SN MN FR TxPort Address Subsystem Namespaces
-------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------

nvme18   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.1   nvme-subsys5 nvme5n1, nvme5n2, nvme5n3, nvme5n4, nvme5n5, nvme5n6
nvme19   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.2   nvme-subsys5 nvme5n1, nvme5n2, nvme5n3, nvme5n4, nvme5n5, nvme5n6
nvme20   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.3   nvme-subsys5 nvme5n1, nvme5n2, nvme5n3, nvme5n4, nvme5n5, nvme5n6
nvme21   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.4   nvme-subsys5 nvme5n1, nvme5n2, nvme5n3, nvme5n4, nvme5n5, nvme5n6
nvme5    S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.0   nvme-subsys5 nvme5n1, nvme5n2, nvme5n3, nvme5n4, nvme5n5, nvme5n6

NVM Express Namespaces

Device NSID Usage Format Controllers
------------ -------- -------------------------- ---------------- ----------------

nvme5n1      1        343.60  GB / 343.60  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21, nvme5
nvme5n2      2        274.88  GB / 274.88  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21, nvme5
nvme5n3      3        283.47  GB / 283.47  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21, nvme5
nvme5n4      4        292.06  GB / 292.06  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21, nvme5
nvme5n5      5        317.83  GB / 317.83  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21, nvme5
nvme5n6      6        137.44  GB / 137.44  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21, nvme5

After the fix we'll get the following right topology:

NVM Express Subsystems

Subsystem Subsystem-NQN Controllers
---------------- ------------------------------------------------------------------------------------------------ ----------------
nvme-subsys5 nqn.1994-11.com.samsung:nvme:PM1733:2.5-inch:S4YNNE0N700448 nvme18, nvme19, nvme20, nvme21, nvme5

NVM Express Controllers

Device SN MN FR TxPort Address Subsystem Namespaces
-------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------

nvme18   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.1   nvme-subsys5 nvme5n2, nvme5n6
nvme19   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.2   nvme-subsys5 nvme5n3, nvme5n6
nvme20   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.3   nvme-subsys5 nvme5n4, nvme5n6
nvme21   S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.4   nvme-subsys5 nvme5n5, nvme5n6
nvme5    S4YNNE0N700448       SAMSUNG MZWLJ1T9HBJR-00007               EPK98B5Q pcie   0000:0a:00.0   nvme-subsys5 nvme5n1

NVM Express Namespaces

Device NSID Usage Format Controllers
------------ -------- -------------------------- ---------------- ----------------

nvme5n1      1        343.60  GB / 343.60  GB    512   B +  0 B   nvme5
nvme5n2      2        274.88  GB / 274.88  GB    512   B +  0 B   nvme18
nvme5n3      3        283.47  GB / 283.47  GB    512   B +  0 B   nvme19
nvme5n4      4        292.06  GB / 292.06  GB    512   B +  0 B   nvme20
nvme5n5      5        317.83  GB / 317.83  GB    512   B +  0 B   nvme21
nvme5n6      6        137.44  GB / 137.44  GB    512   B +  0 B   nvme18, nvme19, nvme20, nvme21
---
 nvme-filters.c  | 16 ++++++++++++
 nvme-print.c    | 66 +++++++++++++++++++++++++++++++++----------------
 nvme-topology.c | 66 ++++++++++++++++++++++++++++++++++++++-----------
 nvme.h          |  1 +
 4 files changed, 114 insertions(+), 35 deletions(-)
nvme-filters.c +16 -0
index a4133f8..17c375f 100644
@@ -7,6 +7,22 @@
 /* global, used for controller specific namespace filter */
 int current_index;
 
+int scan_ctrl_namespace_filter(const struct dirent *d)
+{
+	int c, i, n;
+
+	if (d->d_name[0] == '.')
+		return 0;
+
+	if (strstr(d->d_name, "nvme")) {
+		if (sscanf(d->d_name, "nvme%dc%dn%d", &i, &c, &n) == 3)
+			return 1;
+		if (sscanf(d->d_name, "nvme%dn%d", &i, &n) == 2)
+			return 1;
+	}
+	return 0;
+}
+
 int scan_namespace_filter(const struct dirent *d)
 {
 	int i, n;
nvme-print.c +45 -21

106 lines not on this page · raw message

nvme-topology.c +52 -14

96 lines not on this page · raw message

nvme.h +1 -0
index ffc3fbd..9a54bdb 100644
@@ -97,6 +97,7 @@ char *nvme_char_from_block(char *block);
 void *mmap_registers(const char *dev);
 
 extern int current_index;
+int scan_ctrl_namespace_filter(const struct dirent *d);
 int scan_namespace_filter(const struct dirent *d);
 int scan_ctrl_paths_filter(const struct dirent *d);
 int scan_ctrls_filter(const struct dirent *d);
Signature · 7 lines
2.25.4


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#1 lore raw
Quoted 7 lines · Max Gurtovoy

Currently, nvme-cli assume that all the namespaces in an NVM subsystem are shared between all the controllers. There is an option to create both shared and non-shared namespaces among the controllers in the same NVM subsystem. For example, in SR-IOV environment, one can attach 1 namespace to each controller that will be private and also 1 namespace that will be shared among the secondary controllers only. In this case, the output of "nvme list -v" will be wrong:

Thanks, Max. This looks good, patch applied.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme