[lkml]   [2021]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] scsi: core: Cap shost cmd_per_lun at can_queue
Function sdev_store_queue_depth() enforces that the sdev queue depth cannot
exceed Shost.can_queue.

The sdev initial value comes from shost cmd_per_lun.

However, the LLDD may still set cmd_per_lun > can_queue, which leads to an
initial sdev queue depth greater than can_queue.

Such an issue was reported in [0], which caused a hang. That has since
been fixed in commit fc09acb7de31 ("scsi: scsi_debug: Fix cmd_per_lun,
set to max_queue").

Stop this possibly happening for other drivers by capping
shost.cmd_per_lun at shost.can_queue.


Signed-off-by: John Garry <>
Earlier patch was in

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index ba72bd4202a2..624e2582c3df 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -220,6 +220,9 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
goto fail;

+ shost->cmd_per_lun = min_t(short, shost->cmd_per_lun,
+ shost->can_queue);
error = scsi_init_sense_cache(shost);
if (error)
goto fail;
 \ /
  Last update: 2021-05-19 16:36    [W:0.175 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site