diff mbox series

[V3,for,5.11,11/12] scsi: make sure sdev->queue_depth is <= shost->can_queue

Message ID 20200923013339.1621784-12-ming.lei@redhat.com
State Deferred
Headers show
Series blk-mq/scsi: tracking device queue depth via sbitmap | expand

Commit Message

Ming Lei Sept. 23, 2020, 1:33 a.m. UTC
Obviously scsi device's queue depth can't be > host's can_queue,
so make it explicitely in scsi_change_queue_depth().

Cc: Omar Sandoval <osandov@fb.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Sumanesh Samanta <sumanesh.samanta@broadcom.com>
Cc: Ewan D. Milne <emilne@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/scsi/scsi.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Hannes Reinecke Sept. 23, 2020, 6:47 a.m. UTC | #1
On 9/23/20 3:33 AM, Ming Lei wrote:
> Obviously scsi device's queue depth can't be > host's can_queue,
> so make it explicitely in scsi_change_queue_depth().
> 
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Kashyap Desai <kashyap.desai@broadcom.com>
> Cc: Sumanesh Samanta <sumanesh.samanta@broadcom.com>
> Cc: Ewan D. Milne <emilne@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>   drivers/scsi/scsi.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 24619c3bebd5..cc6ff1ae8c16 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -223,6 +223,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
>    */
>   int scsi_change_queue_depth(struct scsi_device *sdev, int depth)
>   {
> +	depth = min_t(int, depth, sdev->host->can_queue);
> +
>   	if (depth > 0) {
>   		sdev->queue_depth = depth;
>   		wmb();
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
John Garry Sept. 23, 2020, 7:38 a.m. UTC | #2
On 23/09/2020 02:33, Ming Lei wrote:
> Obviously scsi device's queue depth can't be > host's can_queue,
> so make it explicitely in scsi_change_queue_depth().

ha, why not can_queue * nr_hw_queues?

> 
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: Kashyap Desai <kashyap.desai@broadcom.com>
> Cc: Sumanesh Samanta <sumanesh.samanta@broadcom.com>
> Cc: Ewan D. Milne <emilne@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>   drivers/scsi/scsi.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 24619c3bebd5..cc6ff1ae8c16 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -223,6 +223,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
>    */
>   int scsi_change_queue_depth(struct scsi_device *sdev, int depth)
>   {
> +	depth = min_t(int, depth, sdev->host->can_queue);
> +
>   	if (depth > 0) {
>   		sdev->queue_depth = depth;
>   		wmb();
>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 24619c3bebd5..cc6ff1ae8c16 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -223,6 +223,8 @@  void scsi_finish_command(struct scsi_cmnd *cmd)
  */
 int scsi_change_queue_depth(struct scsi_device *sdev, int depth)
 {
+	depth = min_t(int, depth, sdev->host->can_queue);
+
 	if (depth > 0) {
 		sdev->queue_depth = depth;
 		wmb();