[lkml]   [2021]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH AUTOSEL 5.10 27/93] scsi: core: Cap scsi_host cmd_per_lun at can_queue
From: John Garry <>

[ Upstream commit ea2f0f77538c50739b9fb4de4700cee5535e1f77 ]

The sysfs handling function sdev_store_queue_depth() enforces that the sdev
queue depth cannot exceed shost can_queue. The initial sdev queue depth
comes from shost cmd_per_lun. However, the LLDD may manually set
cmd_per_lun to be larger than 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

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


Reviewed-by: Ming Lei <>
Reviewed-by: Bart Van Assche <>
Signed-off-by: John Garry <>
Signed-off-by: Martin K. Petersen <>
Signed-off-by: Sasha Levin <>
drivers/scsi/hosts.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index b93dd8ef4ac8..ce34da53af1b 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-07-10 04:29    [W:0.182 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site