aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagi Grimberg <sagi@grimberg.me>2016-11-27 18:47:40 -0500
committerJens Axboe <axboe@fb.com>2017-02-22 15:34:00 -0500
commit8432bdb2905713cb3ef5cbe4a72630fa575565ad (patch)
treea70caa934fa285b6077925fa510a3fa04299ed72
parent15fbad96fc5fb1c5a0502e6a10dea671f510de3d (diff)
nvme: Make controller state visible via sysfs
Easier for debugging and testing state machine transitions. Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/nvme/host/core.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 44a1a257e0b5..d52978038621 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1577,6 +1577,29 @@ static ssize_t nvme_sysfs_show_transport(struct device *dev,
1577} 1577}
1578static DEVICE_ATTR(transport, S_IRUGO, nvme_sysfs_show_transport, NULL); 1578static DEVICE_ATTR(transport, S_IRUGO, nvme_sysfs_show_transport, NULL);
1579 1579
1580static ssize_t nvme_sysfs_show_state(struct device *dev,
1581 struct device_attribute *attr,
1582 char *buf)
1583{
1584 struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
1585 static const char *const state_name[] = {
1586 [NVME_CTRL_NEW] = "new",
1587 [NVME_CTRL_LIVE] = "live",
1588 [NVME_CTRL_RESETTING] = "resetting",
1589 [NVME_CTRL_RECONNECTING]= "reconnecting",
1590 [NVME_CTRL_DELETING] = "deleting",
1591 [NVME_CTRL_DEAD] = "dead",
1592 };
1593
1594 if ((unsigned)ctrl->state < ARRAY_SIZE(state_name) &&
1595 state_name[ctrl->state])
1596 return sprintf(buf, "%s\n", state_name[ctrl->state]);
1597
1598 return sprintf(buf, "unknown state\n");
1599}
1600
1601static DEVICE_ATTR(state, S_IRUGO, nvme_sysfs_show_state, NULL);
1602
1580static ssize_t nvme_sysfs_show_subsysnqn(struct device *dev, 1603static ssize_t nvme_sysfs_show_subsysnqn(struct device *dev,
1581 struct device_attribute *attr, 1604 struct device_attribute *attr,
1582 char *buf) 1605 char *buf)
@@ -1609,6 +1632,7 @@ static struct attribute *nvme_dev_attrs[] = {
1609 &dev_attr_transport.attr, 1632 &dev_attr_transport.attr,
1610 &dev_attr_subsysnqn.attr, 1633 &dev_attr_subsysnqn.attr,
1611 &dev_attr_address.attr, 1634 &dev_attr_address.attr,
1635 &dev_attr_state.attr,
1612 NULL 1636 NULL
1613}; 1637};
1614 1638