Commit 1f4137e8 authored by Keith Busch's avatar Keith Busch

nvme: move passthrough logging attribute to head

The namespace does not have attributes, but the head does. Move the new
logging attribute to that structure instead of dereferencing the wrong
type.

And while we're here, fix the reverse-tree coding style.

Fixes: 9f079dda ("nvme: allow passthru cmd error logging")
Reported-by: default avatarTasmiya Nalatwad <tasmiya@linux.vnet.ibm.com>
Tested-by: default avatarTasmiya Nalatwad <tasmiya@linux.vnet.ibm.com>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: default avatarAlan Adamson <alan.adamson@oracle.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent f0377ff9
...@@ -713,7 +713,7 @@ void nvme_init_request(struct request *req, struct nvme_command *cmd) ...@@ -713,7 +713,7 @@ void nvme_init_request(struct request *req, struct nvme_command *cmd)
if (req->q->queuedata) { if (req->q->queuedata) {
struct nvme_ns *ns = req->q->disk->private_data; struct nvme_ns *ns = req->q->disk->private_data;
logging_enabled = ns->passthru_err_log_enabled; logging_enabled = ns->head->passthru_err_log_enabled;
req->timeout = NVME_IO_TIMEOUT; req->timeout = NVME_IO_TIMEOUT;
} else { /* no queuedata implies admin queue */ } else { /* no queuedata implies admin queue */
logging_enabled = nr->ctrl->passthru_err_log_enabled; logging_enabled = nr->ctrl->passthru_err_log_enabled;
...@@ -3696,7 +3696,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) ...@@ -3696,7 +3696,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
ns->disk = disk; ns->disk = disk;
ns->queue = disk->queue; ns->queue = disk->queue;
ns->passthru_err_log_enabled = false;
if (ctrl->opts && ctrl->opts->data_digest) if (ctrl->opts && ctrl->opts->data_digest)
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue); blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
......
...@@ -455,6 +455,7 @@ struct nvme_ns_head { ...@@ -455,6 +455,7 @@ struct nvme_ns_head {
struct list_head entry; struct list_head entry;
struct kref ref; struct kref ref;
bool shared; bool shared;
bool passthru_err_log_enabled;
int instance; int instance;
struct nvme_effects_log *effects; struct nvme_effects_log *effects;
u64 nuse; u64 nuse;
...@@ -523,7 +524,6 @@ struct nvme_ns { ...@@ -523,7 +524,6 @@ struct nvme_ns {
struct device cdev_device; struct device cdev_device;
struct nvme_fault_inject fault_inject; struct nvme_fault_inject fault_inject;
bool passthru_err_log_enabled;
}; };
/* NVMe ns supports metadata actions by the controller (generate/strip) */ /* NVMe ns supports metadata actions by the controller (generate/strip) */
......
...@@ -48,8 +48,8 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev, ...@@ -48,8 +48,8 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct nvme_ctrl *ctrl = dev_get_drvdata(dev); struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
int err;
bool passthru_err_log_enabled; bool passthru_err_log_enabled;
int err;
err = kstrtobool(buf, &passthru_err_log_enabled); err = kstrtobool(buf, &passthru_err_log_enabled);
if (err) if (err)
...@@ -60,25 +60,34 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev, ...@@ -60,25 +60,34 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
return count; return count;
} }
static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
{
struct gendisk *disk = dev_to_disk(dev);
if (nvme_disk_is_ns_head(disk))
return disk->private_data;
return nvme_get_ns_from_dev(dev)->head;
}
static ssize_t nvme_io_passthru_err_log_enabled_show(struct device *dev, static ssize_t nvme_io_passthru_err_log_enabled_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct nvme_ns *n = dev_get_drvdata(dev); struct nvme_ns_head *head = dev_to_ns_head(dev);
return sysfs_emit(buf, n->passthru_err_log_enabled ? "on\n" : "off\n"); return sysfs_emit(buf, head->passthru_err_log_enabled ? "on\n" : "off\n");
} }
static ssize_t nvme_io_passthru_err_log_enabled_store(struct device *dev, static ssize_t nvme_io_passthru_err_log_enabled_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct nvme_ns *ns = dev_get_drvdata(dev); struct nvme_ns_head *head = dev_to_ns_head(dev);
int err;
bool passthru_err_log_enabled; bool passthru_err_log_enabled;
int err;
err = kstrtobool(buf, &passthru_err_log_enabled); err = kstrtobool(buf, &passthru_err_log_enabled);
if (err) if (err)
return -EINVAL; return -EINVAL;
ns->passthru_err_log_enabled = passthru_err_log_enabled; head->passthru_err_log_enabled = passthru_err_log_enabled;
return count; return count;
} }
...@@ -91,15 +100,6 @@ static struct device_attribute dev_attr_io_passthru_err_log_enabled = \ ...@@ -91,15 +100,6 @@ static struct device_attribute dev_attr_io_passthru_err_log_enabled = \
__ATTR(passthru_err_log_enabled, S_IRUGO | S_IWUSR, \ __ATTR(passthru_err_log_enabled, S_IRUGO | S_IWUSR, \
nvme_io_passthru_err_log_enabled_show, nvme_io_passthru_err_log_enabled_store); 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);
if (nvme_disk_is_ns_head(disk))
return disk->private_data;
return nvme_get_ns_from_dev(dev)->head;
}
static ssize_t wwid_show(struct device *dev, struct device_attribute *attr, static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
......
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