Commit 8432bdb2 authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Jens Axboe
Browse files

nvme: Make controller state visible via sysfs

Easier for debugging and testing state machine
Signed-off-by: default avatarSagi Grimberg <>
Reviewed-by: default avatarJohannes Thumshirn <>
Reviewed-by: default avatarChristoph Hellwig <>
Signed-off-by: default avatarJens Axboe <>
parent 15fbad96
......@@ -1577,6 +1577,29 @@ static ssize_t nvme_sysfs_show_transport(struct device *dev,
static DEVICE_ATTR(transport, S_IRUGO, nvme_sysfs_show_transport, NULL);
static ssize_t nvme_sysfs_show_state(struct device *dev,
struct device_attribute *attr,
char *buf)
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
static const char *const state_name[] = {
[NVME_CTRL_NEW] = "new",
[NVME_CTRL_LIVE] = "live",
[NVME_CTRL_RESETTING] = "resetting",
[NVME_CTRL_RECONNECTING]= "reconnecting",
[NVME_CTRL_DELETING] = "deleting",
[NVME_CTRL_DEAD] = "dead",
if ((unsigned)ctrl->state < ARRAY_SIZE(state_name) &&
return sprintf(buf, "%s\n", state_name[ctrl->state]);
return sprintf(buf, "unknown state\n");
static DEVICE_ATTR(state, S_IRUGO, nvme_sysfs_show_state, NULL);
static ssize_t nvme_sysfs_show_subsysnqn(struct device *dev,
struct device_attribute *attr,
char *buf)
......@@ -1609,6 +1632,7 @@ static struct attribute *nvme_dev_attrs[] = {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment