scsi: storvsc: Add ability to change scsi queue depth [Linux 5.3]

This Linux kernel change "scsi: storvsc: Add ability to change scsi queue depth" is included in the Linux 5.3 release. This change is authored by Branden Bonaby <brandonbonaby94 [at] gmail.com> on Fri Jun 14 19:48:22 2019 -0400. The commit for this change in Linux stable tree is adfbd02 (patch).

scsi: storvsc: Add ability to change scsi queue depth

Adding functionality to allow the SCSI queue depth to be changed by
utilizing the "scsi_change_queue_depth" function.

[mkp: checkpatch]

Signed-off-by: Branden Bonaby <brandonbonaby94@gmail.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

There are 11 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/scsi/storvsc_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 8472de1..5b6c0f8 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -387,6 +387,7 @@ enum storvsc_request_type {

 static int storvsc_ringbuffer_size = (128 * 1024);
 static u32 max_outstanding_req_per_channel;
+static int storvsc_change_queue_depth(struct scsi_device *sdev, int queue_depth);

 static int storvsc_vcpus_per_sub_channel = 4;

@@ -1711,6 +1712,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
    .dma_boundary =     PAGE_SIZE-1,
    .no_write_same =    1,
    .track_queue_depth =    1,
+   .change_queue_depth =   storvsc_change_queue_depth,
 };

 enum {
@@ -1917,6 +1919,15 @@ static int storvsc_probe(struct hv_device *device,
    return ret;
 }

+/* Change a scsi target's queue depth */
+static int storvsc_change_queue_depth(struct scsi_device *sdev, int queue_depth)
+{
+   if (queue_depth > scsi_driver.can_queue)
+       queue_depth = scsi_driver.can_queue;
+
+   return scsi_change_queue_depth(sdev, queue_depth);
+}
+
 static int storvsc_remove(struct hv_device *dev)
 {
    struct storvsc_device *stor_device = hv_get_drvdata(dev);

Leave a Reply

Your email address will not be published. Required fields are marked *