Commit 4341e907 authored by Bart Van Assche's avatar Bart Van Assche Committed by Zheng Qixing
Browse files

scsi: core: Fix scsi_device_max_queue_depth()

mainline inclusion
from mainline-v5.17-rc1
commit 4bc3bffc
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB4C27

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4bc3bffc1a885eb5cb259e4a25146a4c7b1034e3

-------------------------------------------

The comment above scsi_device_max_queue_depth() and also the description of
commit ca445321 ("scsi: core: Make sure sdev->queue_depth is <=
max(shost->can_queue, 1024)") contradict the implementation of the function
scsi_device_max_queue_depth(). Additionally, the maximum queue depth of a
SCSI LUN never exceeds host->can_queue. Fix scsi_device_max_queue_depth()
by changing max_t() into min_t().

Link: https://lore.kernel.org/r/20211203231950.193369-2-bvanassche@acm.org


Fixes: ca445321 ("scsi: core: Make sure sdev->queue_depth is <= max(shost->can_queue, 1024)")
Cc: Hannes Reinecke <hare@suse.de>
Cc: Sumanesh Samanta <sumanesh.samanta@broadcom.com>
Tested-by: default avatarBean Huo <beanhuo@micron.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarZheng Qixing <zhengqixing@huawei.com>
parent 038b0b76
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -216,11 +216,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd)


/*
 * 1024 is big enough for saturating the fast scsi LUN now
 * 1024 is big enough for saturating fast SCSI LUNs.
 */
int scsi_device_max_queue_depth(struct scsi_device *sdev)
{
	return max_t(int, sdev->host->can_queue, 1024);
	return min_t(int, sdev->host->can_queue, 1024);
}

/**