Skip to contentSkip to conversation

nvme: sysfs: emit the marginal path state in show_state()

PATCH Superseded Bryan Gurney 3 participants 3 messages Jun 20, 2025 – Jun 25, 2025

Subsystems (2)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 6/6 nvme: sysfs: emit the marginal path state in show_state()

If a controller has received a link integrity or congestion event, and has the NVME_CTRL_MARGINAL flag set, emit "marginal" in the state instead of "live", to identify the marginal paths.

---
 drivers/nvme/host/sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/sysfs.c +3 -1
index 29430949ce2f..4a6135c2f9cb 100644
@@ -430,7 +430,9 @@ static ssize_t nvme_sysfs_show_state(struct device *dev,
 	};
 
 	if (state < ARRAY_SIZE(state_name) && state_name[state])
-		return sysfs_emit(buf, "%s\n", state_name[state]);
+		return sysfs_emit(buf, "%s\n",
+			(nvme_ctrl_is_marginal(ctrl)) ? "marginal" :
+			state_name[state]);
 
 	return sysfs_emit(buf, "unknown state\n");
 }
Signature · 1 line
2.49.0
Reviewed-by on v6 6/6
#1 lore raw
Quoted 16 lines · Bryan Gurney

If a controller has received a link integrity or congestion event, and has the NVME_CTRL_MARGINAL flag set, emit "marginal" in the state instead of "live", to identify the marginal paths.

---
  drivers/nvme/host/sysfs.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/sysfs.c +0 -0
index 29430949ce2f..4a6135c2f9cb 100644

drivers/nvme/host/sysfs.c static ssize_t nvme_sysfs_show_state(struct device *dev, · line 438

Quoted 10 lines
drivers/nvme/host/sysfs.c +3 -1
@@ -430,7 +430,9 @@ static ssize_t nvme_sysfs_show_state(struct device *dev,
  	};
 
  	if (state < ARRAY_SIZE(state_name) && state_name[state])
-		return sysfs_emit(buf, "%s\n", state_name[state]);
+		return sysfs_emit(buf, "%s\n",
+			(nvme_ctrl_is_marginal(ctrl)) ? "marginal" :
+			state_name[state]);
 
  	return sysfs_emit(buf, "unknown state\n");
  }

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
Reviewed-by on v6 6/6
#2 lore raw
In reply to Bryan Gurney
Quoted 7 lines · Bryan Gurney

If a controller has received a link integrity or congestion event, and has the NVME_CTRL_MARGINAL flag set, emit "marginal" in the state instead of "live", to identify the marginal paths.

Looks good.

-ck