nvme: Export fast_io_fail_tmo to sysfs
PATCH 1/1 nvme: Export fast_io_fail_tmo to sysfs
Commit 8c4dfea97f15 ("nvme-fabrics: reject I/O to offline device") introduced fast_io_fail_tmo but didn't export the value to sysfs. That means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration.
---
This patch is against nvme-5.13
BTW, checkpatch complains with
WARNING: Symbolic permissions 'S_IRUGO | S_IWUSR' are not preferred. Consider using octal permissions '0644'.
Is this something we want to adapt to?
drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/nvme/host/core.c +31 -0
@@ -3696,6 +3696,36 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR, nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store); +static ssize_t nvme_ctrl_fast_io_fail_tmo_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); + +if (ctrl->opts->fast_io_fail_tmo ==-1 ) +return sprintf (buf,"off\n" ); +return sprintf (buf,"%d\n" , ctrl->opts->fast_io_fail_tmo); +} + +static ssize_t nvme_ctrl_fast_io_fail_tmo_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); +struct nvmf_ctrl_options *opts = ctrl->opts; +int fast_io_fail_tmo, err; + + err =kstrtoint (buf,10 , &fast_io_fail_tmo); +if (err) +return -EINVAL ; + +else if (fast_io_fail_tmo <0 ) + opts->fast_io_fail_tmo =-1 ; +else + opts->fast_io_fail_tmo = fast_io_fail_tmo; +return count; +} +static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, + nvme_ctrl_fast_io_fail_tmo_show, nvme_ctrl_fast_io_fail_tmo_store); +static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr,
@@ -3715,6 +3745,7 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_hostid.attr, &dev_attr_ctrl_loss_tmo.attr, &dev_attr_reconnect_delay.attr, + &dev_attr_fast_io_fail_tmo.attr, NULL };
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 63 lines · Daniel Wagner
Commit
8c4dfea97f15("nvme-fabrics: reject I/O to offline device") introducedfast_io_fail_tmobut didn't export the value to sysfs. That means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration.Cc Victor Gladkov <[email protected]>Signed-off-by Daniel Wagner <[email protected]>---
This patch is against nvme-5.13
BTW, checkpatch complains with
WARNING: Symbolic permissions '
S_IRUGO|S_IWUSR' are not preferred. Consider using octal permissions '0644'.Is this something we want to adapt to?
drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/nvme/host/core.c +30
-0@@ -3696,6 +3696,36 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR, nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store); +static ssize_t nvme_ctrl_fast_io_fail_tmo_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); + +if (ctrl->opts->fast_io_fail_tmo ==-1 ) +return sprintf (buf,"off\n" ); +return sprintf (buf,"%d\n" , ctrl->opts->fast_io_fail_tmo); +} + +static ssize_t nvme_ctrl_fast_io_fail_tmo_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); +struct nvmf_ctrl_options *opts = ctrl->opts; +int fast_io_fail_tmo, err; + + err =kstrtoint (buf,10 , &fast_io_fail_tmo); +if (err) +return -EINVAL ; + +else if (fast_io_fail_tmo <0 ) + opts->fast_io_fail_tmo =-1 ; +else + opts->fast_io_fail_tmo = fast_io_fail_tmo; +return count; +} +static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, + nvme_ctrl_fast_io_fail_tmo_show, nvme_ctrl_fast_io_fail_tmo_store); +static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr,
drivers/nvme/host/core.c static struct attribute *nvme_dev_attrs[] = { · line 3751
Quoted 7 lines
drivers/nvme/host/core.c +1
-0@@ -3715,6 +3745,7 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_hostid.attr, &dev_attr_ctrl_loss_tmo.attr, &dev_attr_reconnect_delay.attr, + &dev_attr_fast_io_fail_tmo.attr, NULL };
It's actually _not_ hardcoded during compilation time, but rather settable via options to 'nvme connect'. But we still should be able to change it after connection has been established.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 5 lines · Hannes Reinecke
Quoted 4 lines · Daniel Wagner
Commit
8c4dfea97f15("nvme-fabrics: reject I/O to offline device") introducedfast_io_fail_tmobut didn't export the value to sysfs. That means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration.
[...]
Quoted 3 lines
It's actually _not_ hardcoded during compilation time, but rather settable via options to 'nvme connect'. But we still should be able to change it after connection has been established.
Ah, yes, I didn't realize it. Best to drop the sentence I suppose. Shall I send v2?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 68 lines · Daniel Wagner
Commit
8c4dfea97f15("nvme-fabrics: reject I/O to offline device") introducedfast_io_fail_tmobut didn't export the value to sysfs. That
means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration.Cc Victor Gladkov <[email protected]>Signed-off-by Daniel Wagner <[email protected]>---
This patch is against nvme-5.13
BTW, checkpatch complains with
WARNING: Symbolic permissions '
S_IRUGO|S_IWUSR' are not
preferred. Consider using octal permissions '0644'.Is this something we want to adapt to?
drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/nvme/host/core.c +29
-0@@ -3696,6 +3696,36 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR, nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store); +static ssize_t nvme_ctrl_fast_io_fail_tmo_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); + +if (ctrl->opts->fast_io_fail_tmo ==-1 ) +return sprintf (buf,"off\n" ); +return sprintf (buf,"%d\n" , ctrl->opts->fast_io_fail_tmo); +} + +static ssize_t nvme_ctrl_fast_io_fail_tmo_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); +struct nvmf_ctrl_options *opts = ctrl->opts; +int fast_io_fail_tmo, err; + + err =kstrtoint (buf,10 , &fast_io_fail_tmo); +if (err) +return -EINVAL ; + +else if (fast_io_fail_tmo <0 ) + opts->fast_io_fail_tmo =-1 ; +else + opts->fast_io_fail_tmo = fast_io_fail_tmo; +return count; +} +static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, + nvme_ctrl_fast_io_fail_tmo_show,
nvme_ctrl_fast_io_fail_tmo_store);drivers/nvme/host/core.c +1
-0+static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr,
drivers/nvme/host/core.c static struct attribute *nvme_dev_attrs[] = { · line 3751
Quoted 7 lines
drivers/nvme/host/core.c +1
-0@@ -3715,6 +3745,7 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_hostid.attr, &dev_attr_ctrl_loss_tmo.attr, &dev_attr_reconnect_delay.attr, + &dev_attr_fast_io_fail_tmo.attr, NULL };
Thanks.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 76 lines · Daniel Wagner
Commit
8c4dfea97f15("nvme-fabrics: reject I/O to offline device") introducedfast_io_fail_tmobut didn't export the value to sysfs. That means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration.Cc Victor Gladkov <[email protected]>Signed-off-by Daniel Wagner <[email protected]>---
This patch is against nvme-5.13
BTW, checkpatch complains with
WARNING: Symbolic permissions '
S_IRUGO|S_IWUSR' are not preferred. Consider using octal permissions '0644'.Is this something we want to adapt to?
drivers/nvme/host/core.c| 31 +++++++++++++++++++++++++++++++1 file changed, 31 insertions(+)drivers/nvme/host/core.c +31
-0@@ -3696,6 +3696,36 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR, nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store); +static ssize_t nvme_ctrl_fast_io_fail_tmo_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); + +if (ctrl->opts->fast_io_fail_tmo ==-1 ) +return sprintf (buf,"off\n" ); +return sprintf (buf,"%d\n" , ctrl->opts->fast_io_fail_tmo); +} + +static ssize_t nvme_ctrl_fast_io_fail_tmo_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); +struct nvmf_ctrl_options *opts = ctrl->opts; +int fast_io_fail_tmo, err; + + err =kstrtoint (buf,10 , &fast_io_fail_tmo); +if (err) +return -EINVAL ; + +else if (fast_io_fail_tmo <0 ) + opts->fast_io_fail_tmo =-1 ; +else + opts->fast_io_fail_tmo = fast_io_fail_tmo; +return count; +} +static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, + nvme_ctrl_fast_io_fail_tmo_show, nvme_ctrl_fast_io_fail_tmo_store); +static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr,@@ -3715,6 +3745,7 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_hostid.attr, &dev_attr_ctrl_loss_tmo.attr, &dev_attr_reconnect_delay.attr, + &dev_attr_fast_io_fail_tmo.attr, NULL };Signature · 1 line
2.29.2
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Daniel,
Quoted 7 lines · Daniel Wagner
Commit
8c4dfea97f15("nvme-fabrics: reject I/O to offline device") introducedfast_io_fail_tmobut didn't export the value to sysfs. That means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration.Cc Victor Gladkov <[email protected]>Signed-off-by Daniel Wagner <[email protected]>
Quoted 7 lines
---
This patch is against nvme-5.13
BTW, checkpatch complains with
WARNING: Symbolic permissions '
S_IRUGO|S_IWUSR' are not preferred. Consider using octal permissions '0644'.
For now keep the current style.
Quoted 12 lines
Is this something we want to adapt to?
drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/nvme/host/core.c +0
-0@@ -3696,6 +3696,36 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR,
drivers/nvme/host/core.c static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, · line 3706
Quoted 10 lines
drivers/nvme/host/core.c +8
-0nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store); +static ssize_t nvme_ctrl_fast_io_fail_tmo_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); + +if (ctrl->opts->fast_io_fail_tmo ==-1 ) +return sprintf (buf,"off\n" ); +return sprintf (buf,"%d\n" , ctrl->opts->fast_io_fail_tmo);
do we need snprintf() for 2nd ?
drivers/nvme/host/core.c static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, · line 3719
Quoted 13 lines
drivers/nvme/host/core.c +13
-0+} + +static ssize_t nvme_ctrl_fast_io_fail_tmo_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct nvme_ctrl *ctrl =dev_get_drvdata (dev); +struct nvmf_ctrl_options *opts = ctrl->opts; +int fast_io_fail_tmo, err; + + err =kstrtoint (buf,10 , &fast_io_fail_tmo); +if (err) +return -EINVAL ; +
since you are returning an error, you can remove next else if, this also removes the extra line after above return. Something like this on the top of yours totally untested :-
drivers/nvme/host/core.c +0 -0
@@ -3717,7 +3717,7 @@ static ssize_t
nvme_ctrl_fast_io_fail_tmo_store(struct device *dev,
if (err)
return -EINVAL;- else if (fast_io_fail_tmo < 0)
+ if (fast_io_fail_tmo < 0)
opts->fast_io_fail_tmo = -1;
else
opts->fast_io_fail_tmo = fast_io_fail_tmo;Quoted 13 lines
drivers/nvme/host/core.c +9
-0+else if (fast_io_fail_tmo <0 ) + opts->fast_io_fail_tmo =-1 ; +else + opts->fast_io_fail_tmo = fast_io_fail_tmo; +return count; +} +static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, + nvme_ctrl_fast_io_fail_tmo_show, nvme_ctrl_fast_io_fail_tmo_store); +static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr,
drivers/nvme/host/core.c static struct attribute *nvme_dev_attrs[] = {
Quoted 8 lines
drivers/nvme/host/core.c +1
-1@@ -3715,6 +3745,7 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_hostid.attr, &dev_attr_ctrl_loss_tmo.attr, &dev_attr_reconnect_delay.attr, + &dev_attr_fast_io_fail_tmo.attr, NULL }; -- 2.29.2
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Hi Chaitanya,
Quoted 3 lines · Chaitanya Kulkarni
Quoted 1 line
WARNING: Symbolic permissions '
S_IRUGO|S_IWUSR' are not preferred. Consider using octal permissions '0644'.For now keep the current style.
Okay, I thought so too. I am just wondering if a patch for changing all the permission sets is acceptable. I prefer the the octal permissions ;)
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+static ssize_t nvme_ctrl_fast_io_fail_tmo_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + + if (ctrl->opts->fast_io_fail_tmo == -1) + return sprintf(buf, "off\n"); + return sprintf(buf, "%d\n", ctrl->opts->fast_io_fail_tmo);do we need
snprintf()for 2nd ?
Sure thing can do. Also here I followed the existing style. The other store functions tend to use sprintf().
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ err = kstrtoint(buf, 10, &fast_io_fail_tmo); + if (err) + return -EINVAL; +since you are returning an error, you can remove next else if, this also removes the extra line after above return. Something like this on the top of yours totally untested :-
Right, same here, followed the existing style. I prepare a patch which addresses your comments for the existing code as well.
Thanks,
Daniel
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme