From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: bvanassche@acm.org, James Smart <jsmart2021@gmail.com>
Subject: [PATCH v3 1/3] scsi: refactor sdev lun queue depth setting via sysfs
Date: Fri, 24 Jan 2020 15:01:13 -0800 [thread overview]
Message-ID: <20200124230115.14562-2-jsmart2021@gmail.com> (raw)
In-Reply-To: <20200124230115.14562-1-jsmart2021@gmail.com>
In preparation for allowing other attributes and routines to change
the current and max lun queue depth on an sdev, refactor the sysfs
sdev attribute change routine. The refactoring creates a new scsi-internal
routine, scsi_change_max_queue_depth(), which changes a devices current
and max queue value.
The new routine is placed next to the routine, scsi_change_queue_depth(),
which is used by most lldds to implement a queue depth change.
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
v3:
revert -ENOTSUPP status on shost template check back to -EINVAL
---
drivers/scsi/scsi.c | 22 ++++++++++++++++++++++
drivers/scsi/scsi_priv.h | 1 +
drivers/scsi/scsi_sysfs.c | 7 ++-----
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 930e4803d888..195c0b11260a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -249,6 +249,28 @@ int scsi_change_queue_depth(struct scsi_device *sdev, int depth)
}
EXPORT_SYMBOL(scsi_change_queue_depth);
+/*
+ * scsi_change_max_queue_depth - change the max queue depth for a device.
+ * @sdev: SCSI Device in question
+ * @depth: number of commands allowed to be queued to the driver
+ *
+ * Calls the device's transport to validate and change the queue depth,
+ * then stores the new maximum on the device.
+ */
+int
+scsi_change_max_queue_depth(struct scsi_device *sdev, int depth)
+{
+ int retval;
+
+ retval = sdev->host->hostt->change_queue_depth(sdev, depth);
+ if (retval < 0)
+ return retval;
+
+ sdev->max_queue_depth = sdev->queue_depth;
+
+ return 0;
+}
+
/**
* scsi_track_queue_full - track QUEUE_FULL events to adjust queue depth
* @sdev: SCSI Device in question
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 3bff9f7aa684..5c288cf3ae64 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -41,6 +41,7 @@ static inline void scsi_log_send(struct scsi_cmnd *cmd)
static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
{ };
#endif
+int scsi_change_max_queue_depth(struct scsi_device *sdev, int depth);
/* scsi_devinfo.c */
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 677b5c5403d2..d4e9ad9a6f18 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -982,9 +982,8 @@ sdev_store_queue_depth(struct device *dev, struct device_attribute *attr,
{
int depth, retval;
struct scsi_device *sdev = to_scsi_device(dev);
- struct scsi_host_template *sht = sdev->host->hostt;
- if (!sht->change_queue_depth)
+ if (!sdev->host->hostt->change_queue_depth)
return -EINVAL;
depth = simple_strtoul(buf, NULL, 0);
@@ -992,12 +991,10 @@ sdev_store_queue_depth(struct device *dev, struct device_attribute *attr,
if (depth < 1 || depth > sdev->host->can_queue)
return -EINVAL;
- retval = sht->change_queue_depth(sdev, depth);
+ retval = scsi_change_max_queue_depth(sdev, depth);
if (retval < 0)
return retval;
- sdev->max_queue_depth = sdev->queue_depth;
-
return count;
}
sdev_show_function(queue_depth, "%d\n");
--
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 ` James Smart [this message]
2020-01-25 5:54 ` [PATCH v3 1/3] scsi: refactor sdev lun queue depth setting via sysfs Bart Van Assche
2020-01-24 23:01 ` [PATCH v3 2/3] scsi: add shost helper to set max queue depth on all of its devices James Smart
2020-01-25 5:53 ` 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-2-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