[PATCH 3/3] nvme: export delay_io_retry_time to sysfs

Jiewei Ke jiewei at smartx.com
Thu Apr 10 05:20:54 PDT 2025


Export the delay_io_retry_time value to user space via sysfs to allow
runtime configuration.

Signed-off-by: Jiewei Ke <jiewei at smartx.com>
---
 drivers/nvme/host/sysfs.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 6d31226f7a4f..d3fb39ea7728 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -684,6 +684,40 @@ static DEVICE_ATTR(dhchap_ctrl_secret, S_IRUGO | S_IWUSR,
 	nvme_ctrl_dhchap_ctrl_secret_show, nvme_ctrl_dhchap_ctrl_secret_store);
 #endif
 
+static ssize_t nvme_ctrl_delay_io_retry_time_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+
+	if (ctrl->opts->delay_io_retry_time == 0)
+		return sysfs_emit(buf, "off\n");
+	return sysfs_emit(buf, "%d\n", ctrl->opts->delay_io_retry_time);
+}
+
+static ssize_t nvme_ctrl_delay_io_retry_time_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 delay_io_retry_time, err;
+
+	err = kstrtoint(buf, 10, &delay_io_retry_time);
+	if (err)
+		return -EINVAL;
+
+	if (strcmp(opts->transport, "tcp") != 0 && strcmp(opts->transport, "rdma") != 0)
+		return -EINVAL;
+
+	if (delay_io_retry_time < 0)
+		opts->delay_io_retry_time = 0;
+	else
+		opts->delay_io_retry_time = delay_io_retry_time;
+	return count;
+}
+
+static DEVICE_ATTR(delay_io_retry_time, S_IRUGO | S_IWUSR,
+	nvme_ctrl_delay_io_retry_time_show, nvme_ctrl_delay_io_retry_time_store);
+
 static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_reset_controller.attr,
 	&dev_attr_rescan_controller.attr,
@@ -712,6 +746,7 @@ static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_dhchap_ctrl_secret.attr,
 #endif
 	&dev_attr_adm_passthru_err_log_enabled.attr,
+	&dev_attr_delay_io_retry_time.attr,
 	NULL
 };
 
@@ -741,6 +776,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
 	if (a == &dev_attr_dhchap_ctrl_secret.attr && !ctrl->opts)
 		return 0;
 #endif
+	if (a == &dev_attr_delay_io_retry_time.attr && !ctrl->opts)
+		return 0;
 
 	return a->mode;
 }
-- 
2.36.0




More information about the Linux-nvme mailing list