mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
nvme: allow passthru cmd error logging
Commit d7ac8dca93 ("nvme: quiet user passthrough command errors")
disabled error logging for user passthrough commands. This commit
adds the ability to opt-in to passthrough admin error logging. IO
commands initiated as passthrough will always be logged.
The logging output for passthrough commands (Admin and IO) has been
changed to include CDWXX fields.
nvme0n1: Read(0x2), LBA Out of Range (sct 0x0 / sc 0x80) DNR cdw10=0x0 cdw11=0x1
cdw12=0x70000 cdw13=0x0 cdw14=0x0 cdw15=0x0
Add a helper function nvme_log_err_passthru() which allows us to log
error for passthru commands by decoding cdw10-cdw15 values of nvme
command.
Add a new sysfs attr passthru_err_log_enabled that allows user to conditionally
enable passthrough command logging for either passthrough Admin commands sent to
the controller or passthrough IO commands sent to a namespace.
By default, passthrough error logging is disabled.
To enable passthrough admin error logging:
echo 1 > /sys/class/nvme/nvme0/passthru_err_log_enabled
To disable passthrough admin error logging:
echo 0 > /sys/class/nvme/nvme0/passthru_err_log_enabled
To enable passthrough io error logging:
echo 1 > /sys/class/nvme/nvme0/nvme0n1/passthru_err_log_enabled
To disable passthrough io error logging:
echo 0 > /sys/class/nvme/nvme0/nvme0n1/passthru_err_log_enabled
Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
committed by
Keith Busch
parent
c3a846fe4b
commit
9f079dda14
@@ -35,6 +35,62 @@ static ssize_t nvme_sysfs_rescan(struct device *dev,
|
||||
}
|
||||
static DEVICE_ATTR(rescan_controller, S_IWUSR, NULL, nvme_sysfs_rescan);
|
||||
|
||||
static ssize_t nvme_adm_passthru_err_log_enabled_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
|
||||
|
||||
return sysfs_emit(buf,
|
||||
ctrl->passthru_err_log_enabled ? "on\n" : "off\n");
|
||||
}
|
||||
|
||||
static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
|
||||
int err;
|
||||
bool passthru_err_log_enabled;
|
||||
|
||||
err = kstrtobool(buf, &passthru_err_log_enabled);
|
||||
if (err)
|
||||
return -EINVAL;
|
||||
|
||||
ctrl->passthru_err_log_enabled = passthru_err_log_enabled;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t nvme_io_passthru_err_log_enabled_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct nvme_ns *n = dev_get_drvdata(dev);
|
||||
|
||||
return sysfs_emit(buf, n->passthru_err_log_enabled ? "on\n" : "off\n");
|
||||
}
|
||||
|
||||
static ssize_t nvme_io_passthru_err_log_enabled_store(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct nvme_ns *ns = dev_get_drvdata(dev);
|
||||
int err;
|
||||
bool passthru_err_log_enabled;
|
||||
|
||||
err = kstrtobool(buf, &passthru_err_log_enabled);
|
||||
if (err)
|
||||
return -EINVAL;
|
||||
ns->passthru_err_log_enabled = passthru_err_log_enabled;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static struct device_attribute dev_attr_adm_passthru_err_log_enabled = \
|
||||
__ATTR(passthru_err_log_enabled, S_IRUGO | S_IWUSR, \
|
||||
nvme_adm_passthru_err_log_enabled_show, nvme_adm_passthru_err_log_enabled_store);
|
||||
|
||||
static struct device_attribute dev_attr_io_passthru_err_log_enabled = \
|
||||
__ATTR(passthru_err_log_enabled, S_IRUGO | S_IWUSR, \
|
||||
nvme_io_passthru_err_log_enabled_show, nvme_io_passthru_err_log_enabled_store);
|
||||
|
||||
static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
|
||||
{
|
||||
struct gendisk *disk = dev_to_disk(dev);
|
||||
@@ -208,6 +264,7 @@ static struct attribute *nvme_ns_attrs[] = {
|
||||
&dev_attr_ana_grpid.attr,
|
||||
&dev_attr_ana_state.attr,
|
||||
#endif
|
||||
&dev_attr_io_passthru_err_log_enabled.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@@ -655,6 +712,7 @@ static struct attribute *nvme_dev_attrs[] = {
|
||||
#ifdef CONFIG_NVME_TCP_TLS
|
||||
&dev_attr_tls_key.attr,
|
||||
#endif
|
||||
&dev_attr_adm_passthru_err_log_enabled.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user