From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: bvanassche@acm.org, James Smart <jsmart2021@gmail.com>
Subject: [PATCH v3 2/3] scsi: add shost helper to set max queue depth on all of its devices
Date: Fri, 24 Jan 2020 15:01:14 -0800 [thread overview]
Message-ID: <20200124230115.14562-3-jsmart2021@gmail.com> (raw)
In-Reply-To: <20200124230115.14562-1-jsmart2021@gmail.com>
Create a helper routine to loop through all devices on an shost and
change their current and maximum queue depth. The helper is created
such that is lldd callable.
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
v3:
fix spaces
change ENOTSUPP to ENXIO
---
drivers/scsi/scsi.c | 32 ++++++++++++++++++++++++++++++++
include/scsi/scsi_device.h | 1 +
2 files changed, 33 insertions(+)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 195c0b11260a..86db018bacb2 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -272,6 +272,38 @@ scsi_change_max_queue_depth(struct scsi_device *sdev, int depth)
}
/**
+ * shost_change_max_queue_depths - helper to walk all devices on a
+ * shost and change their max queue depth.
+ * @shost: shost whose devices we want to iterate over.
+ * @depth: number of commands allowed to be queued to the driver
+ *
+ * Validates the shost allows a change of queue depth, the value is valid,
+ * then traverses over all devices and sets their maximum queue depth.
+ */
+int shost_change_max_queue_depths(struct Scsi_Host *shost, int depth)
+{
+ struct scsi_device *sdev;
+ int retval;
+
+ if (!shost->hostt->change_queue_depth)
+ return -ENXIO;
+
+ if (depth < 1 || depth > shost->can_queue)
+ return -EINVAL;
+
+ shost_for_each_device(sdev, shost) {
+ retval = scsi_change_max_queue_depth(sdev, depth);
+ if (retval != 0)
+ sdev_printk(KERN_INFO, sdev,
+ "failed to set queue depth to %d (err %d)",
+ depth, retval);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(shost_change_max_queue_depths);
+
+/**
* scsi_track_queue_full - track QUEUE_FULL events to adjust queue depth
* @sdev: SCSI Device in question
* @depth: Current number of outstanding SCSI commands on this device,
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index f8312a3e5b42..38c4b97fc1b8 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -392,6 +392,7 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
extern int scsi_change_queue_depth(struct scsi_device *, int);
extern int scsi_track_queue_full(struct scsi_device *, int);
+extern int shost_change_max_queue_depths(struct Scsi_Host *shost, int depth);
extern int scsi_set_medium_removal(struct scsi_device *, char);
--
2.13.7
next prev parent reply other threads:[~2020-01-24 23:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-24 23:01 [PATCH v3 0/3] scsi: add attribute to set lun queue depth on all luns on shost James Smart
2020-01-24 23:01 ` [PATCH v3 1/3] scsi: refactor sdev lun queue depth setting via sysfs James Smart
2020-01-25 5:54 ` Bart Van Assche
2020-01-24 23:01 ` James Smart [this message]
2020-01-25 5:53 ` [PATCH v3 2/3] scsi: add shost helper to set max queue depth on all of its devices Bart Van Assche
2020-01-24 23:01 ` [PATCH v3 3/3] scsi: add shost attribute to set max queue depth on all devices on the shost James Smart
2020-01-25 5:51 ` Bart Van Assche
2020-02-05 2:56 ` [PATCH v3 0/3] scsi: add attribute to set lun queue depth on all luns on shost Martin K. Petersen
2020-02-05 18:57 ` James Smart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200124230115.14562-3-jsmart2021@gmail.com \
--to=jsmart2021@gmail.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox