Skip to contentSkip to conversation

nvme-multipath: expose path_state via sysfs

PATCH Applied Guixin Liu 5 participants 6 messages Sep 20 – Sep 22 NVMe

lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

v5 cover nvme-multipath: expose path_state via sysfs

This series adds a read-only "path_state" sysfs attribute to each NVMe multipath path namespace device (/sys/block/nvmeXcYnZ/path_state), giving userspace visibility into whether a path is currently usable for I/O and, if not, the reason it is disabled.

Today users have to piece this together from the controller state and various namespace flags. The new attribute reports the path selection state directly, and is kept in sync with the path selection logic by sharing a single nvme_path_get_state() helper.

Changes since v4:
- Merge the two patches into one patch. (Christoph Hellwig)
- Change the new ABI's KernelVersion from 7.2 to 7.4.

Changes since v3:
- Use single-token sysfs values ("enabled", "ctrl-down", "ana-pending", "ns-not-ready") instead of the composite "disabled (reason)" and "enabled (optimized)/(non-optimized)" strings, following the sysfs convention of exporting one simple value per attribute.
- Drop the "enabled (optimized)" vs "enabled (non-optimized)" distinction; the ANA access state is already exposed through the existing per-path ana_state attribute.
- Add a second patch documenting path_state in the stable NVMe sysfs ABI (Documentation/ABI/stable/sysfs-nvme).

Changes since v2:
- Factor path disable checks into nvme_path_get_state() helper returning enum nvme_path_state, and rebuild nvme_path_is_disabled() on top of it to keep path selection logic and sysfs reporting in sync. (Nilay Shroff)
- Distinguish "enabled (optimized)" vs "enabled (non-optimized)" based on ANA state. (Keith Busch)

Changes since v1:
- Show specific disabled reason instead of just "disabled":
"disabled (ctrl_down)", "disabled (ana_pending)", "disabled (ns_not_ready)". (Nilay Shroff)

Guixin Liu (1):
nvme-multipath: expose path_state via sysfs

 Documentation/ABI/stable/sysfs-nvme | 21 +++++++++++++
 drivers/nvme/host/multipath.c       | 47 +++++++++++++++++++++++++----
 drivers/nvme/host/nvme.h            |  1 +
 drivers/nvme/host/sysfs.c           |  4 ++-
 4 files changed, 66 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.7
author
#1 lore raw

PATCH v5 1/1 nvme-multipath: expose path_state via sysfs

Add a read-only "path_state" sysfs attribute to each NVMe path namespace device (/sys/class/nvme/nvmeX/nvmeXcYnZ/path_state) that exposes the current path state, including whether the path is enabled or disabled with a specific reason.

Factor the path disable checks from nvme_path_is_disabled() into a new nvme_path_get_state() helper that returns an enum nvme_path_state. This keeps the path selection logic and sysfs reporting in sync, so any future updates to the path disable criteria are automatically reflected in the sysfs output.

Possible values:

  - "enabled"      : path is usable for I/O
  - "ctrl-down"    : controller is not live
  - "ana-pending"  : ANA state change pending

- "ns-not-ready" : namespace is not ready

This gives userspace visibility into the multipath path selection state without requiring users to piece together controller state and namespace flags manually.

---
 Documentation/ABI/stable/sysfs-nvme | 21 +++++++++++++
 drivers/nvme/host/multipath.c       | 47 +++++++++++++++++++++++++----
 drivers/nvme/host/nvme.h            |  1 +
 drivers/nvme/host/sysfs.c           |  4 ++-
 4 files changed, 66 insertions(+), 7 deletions(-)
Documentation/ABI/stable/sysfs-nvme +21 -0
index a2f5d0710db4..a0bb88ca1694 100644
@@ -326,6 +326,27 @@ Description:
 		currently selected path. Returns empty if iopolicy is not
 		"numa". Requires CONFIG_NVME_MULTIPATH.
 
+What:		/sys/block/nvmeXcYnZ/path_state
+Date:		September 2026
+KernelVersion:	7.4
+Contact:	Guixin Liu <[email protected]>
+Description:
+		Shows the current multipath path state for this namespace
+		path device. Possible values:
+
+		"enabled": the path is usable for I/O.
+
+		"ctrl-down": the path is disabled because the controller
+		is not live.
+
+		"ana-pending": the path is disabled because an ANA state
+		change is pending.
+
+		"ns-not-ready": the path is disabled because the namespace
+		is not ready.
+
+		Requires CONFIG_NVME_MULTIPATH.
+
 What:		/sys/block/nvmeXnY/delayed_removal_secs
 Date:		May 2025
 KernelVersion:	6.16
drivers/nvme/host/multipath.c +41 -6

65 lines not on this page · raw message

drivers/nvme/host/nvme.h +1 -0
index 824651cc898d..9a9af2a24136 100644
@@ -1075,6 +1075,7 @@ extern struct device_attribute dev_attr_ana_grpid;
 extern struct device_attribute dev_attr_ana_state;
 extern struct device_attribute dev_attr_queue_depth;
 extern struct device_attribute dev_attr_numa_nodes;
+extern struct device_attribute dev_attr_path_state;
 extern struct device_attribute dev_attr_delayed_removal_secs;
 extern struct device_attribute dev_attr_multipath_failover_count;
 extern struct device_attribute dev_attr_io_requeue_no_usable_path_count;
drivers/nvme/host/sysfs.c +3 -1
index 75b2d69b5957..c457a2c67c0b 100644
@@ -261,6 +261,7 @@ static struct attribute *nvme_ns_attrs[] = {
 	&dev_attr_ana_state.attr,
 	&dev_attr_queue_depth.attr,
 	&dev_attr_numa_nodes.attr,
+	&dev_attr_path_state.attr,
 	&dev_attr_delayed_removal_secs.attr,
 #endif
 	&dev_attr_io_passthru_err_log_enabled.attr,
@@ -294,7 +295,8 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
 		if (!nvme_ctrl_use_ana(nvme_get_ns_from_dev(dev)->ctrl))
 			return 0;
 	}
-	if (a == &dev_attr_queue_depth.attr || a == &dev_attr_numa_nodes.attr) {
+	if (a == &dev_attr_queue_depth.attr || a == &dev_attr_numa_nodes.attr ||
+	    a == &dev_attr_path_state.attr) {
 		if (nvme_disk_is_ns_head(dev_to_disk(dev)))
 			return 0;
 	}
Signature · 1 line
2.43.7
Reviewed-by on v5 1/1
#2 lore raw
Quoted 15 lines · Guixin Liu

Add a read-only "path_state" sysfs attribute to each NVMe path namespace device (/sys/class/nvme/nvmeX/nvmeXcYnZ/path_state) that exposes the current path state, including whether the path is enabled or disabled with a specific reason.

Factor the path disable checks from nvme_path_is_disabled() into a new nvme_path_get_state() helper that returns an enum nvme_path_state. This keeps the path selection logic and sysfs reporting in sync, so any future updates to the path disable criteria are automatically reflected in the sysfs output.

Possible values:

   - "enabled"      : path is usable for I/O
   - "ctrl-down"    : controller is not live
   - "ana-pending"  : ANA state change pending
Quoted 7 lines

- "ns-not-ready" : namespace is not ready

This gives userspace visibility into the multipath path selection state without requiring users to piece together controller state and namespace flags manually.

Looks good to me.

Reviewed-by on v5 1/1
#4 lore raw
In reply to Guixin Liu
Quoted 21 lines · Guixin Liu

Add a read-only "path_state" sysfs attribute to each NVMe path namespace device (/sys/class/nvme/nvmeX/nvmeXcYnZ/path_state) that exposes the current path state, including whether the path is enabled or disabled with a specific reason.

Factor the path disable checks from nvme_path_is_disabled() into a new nvme_path_get_state() helper that returns an enum nvme_path_state. This keeps the path selection logic and sysfs reporting in sync, so any future updates to the path disable criteria are automatically reflected in the sysfs output.

Possible values:

   - "enabled"      : path is usable for I/O
   - "ctrl-down"    : controller is not live
   - "ana-pending"  : ANA state change pending

- "ns-not-ready" : namespace is not ready

This gives userspace visibility into the multipath path selection state without requiring users to piece together controller state and namespace flags manually.

Quoted 8 lines
---
  Documentation/ABI/stable/sysfs-nvme | 21 +++++++++++++
  drivers/nvme/host/multipath.c       | 47 +++++++++++++++++++++++++----
  drivers/nvme/host/nvme.h            |  1 +
  drivers/nvme/host/sysfs.c           |  4 ++-
  4 files changed, 66 insertions(+), 7 deletions(-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
maintainer Applied
#5 lore raw
In reply to Guixin Liu
Quoted 12 lines · Guixin Liu

Add a read-only "path_state" sysfs attribute to each NVMe path namespace device (/sys/class/nvme/nvmeX/nvmeXcYnZ/path_state) that exposes the current path state, including whether the path is enabled or disabled with a specific reason.

Factor the path disable checks from nvme_path_is_disabled() into a new nvme_path_get_state() helper that returns an enum nvme_path_state. This keeps the path selection logic and sysfs reporting in sync, so any future updates to the path disable criteria are automatically reflected in the sysfs output.

Possible values:

Quoted 8 lines
  - "enabled"      : path is usable for I/O
  - "ctrl-down"    : controller is not live
  - "ana-pending"  : ANA state change pending

- "ns-not-ready" : namespace is not ready

This gives userspace visibility into the multipath path selection state without requiring users to piece together controller state and namespace flags manually.

Thanks, applied to nvme-7.4.