diff mbox series

[v2,3/3] scsi: add shost attribute to set max queue depth on all devices on the shost

Message ID 20200123222102.23383-4-jsmart2021@gmail.com (mailing list archive)
State Superseded
Headers show
Series scsi: add attribute to set lun queue depth on all luns on shost | expand

Commit Message

James Smart Jan. 23, 2020, 10:21 p.m. UTC
This patch adds an shost attribute, max_device_queue_depth, that will
cycle through all devices on the shost and change their current and max
queue depth to the new value.

Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/scsi_sysfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Bart Van Assche Jan. 24, 2020, 2:55 a.m. UTC | #1
On 2020-01-23 14:21, James Smart wrote:
> +	depth = simple_strtoul(buf, NULL, 0);

From Documentation/process/deprecated.rst:

The :c:func:`simple_strtol`, :c:func:`simple_strtoll`,
:c:func:`simple_strtoul`, and :c:func:`simple_strtoull` functions
explicitly ignore overflows, which may lead to unexpected results
in callers. The respective :c:func:`kstrtol`, :c:func:`kstrtoll`,
:c:func:`kstrtoul`, and :c:func:`kstrtoull` functions tend to be the
correct replacements, though note that those require the string to be
NUL or newline terminated.

Did checkpatch recommend to use kstrtoul() instead?

> +	return (retval < 0) ? retval : count;

Are the parentheses necessary in this expression?

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 954f68b002cb..85dab4867eed 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -368,6 +368,23 @@  store_shost_eh_deadline(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR(eh_deadline, S_IRUGO | S_IWUSR, show_shost_eh_deadline, store_shost_eh_deadline);
 
+static ssize_t
+store_host_max_device_queue_depth(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct Scsi_Host *shost = class_to_shost(dev);
+	int depth, retval;
+
+	depth = simple_strtoul(buf, NULL, 0);
+
+	retval = shost_change_max_queue_depths(shost, depth);
+
+	return (retval < 0) ? retval : count;
+}
+
+static DEVICE_ATTR(max_device_queue_depth, S_IWUSR, NULL,
+		   store_host_max_device_queue_depth);
+
 shost_rd_attr(unique_id, "%u\n");
 shost_rd_attr(cmd_per_lun, "%hd\n");
 shost_rd_attr(can_queue, "%hd\n");
@@ -411,6 +428,7 @@  static struct attribute *scsi_sysfs_shost_attrs[] = {
 	&dev_attr_prot_guard_type.attr,
 	&dev_attr_host_reset.attr,
 	&dev_attr_eh_deadline.attr,
+	&dev_attr_max_device_queue_depth.attr,
 	NULL
 };