From: Ming Lei <ming.lei@redhat.com>
To: John Garry <john.garry@huawei.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org, martin.petersen@oracle.com,
jejb@linux.vnet.ibm.com, kashyap.desai@broadcom.com,
axboe@kernel.dk
Subject: Re: [PATCH] scsi_debug: fix cmd_per_lun, set to max_queue
Date: Fri, 16 Apr 2021 09:46:05 +0800 [thread overview]
Message-ID: <YHjsXaVJJsQXwEPW@T590> (raw)
In-Reply-To: <580349dc-0152-8f39-5f3c-be9115e3bf12@huawei.com>
On Thu, Apr 15, 2021 at 10:15:27AM +0100, John Garry wrote:
> This looks ok.
>
> Apart from this, I tested linux-next (without this patch) - which includes
> Ming's changes to replace sdev-->device_busy with sbitmap - and, as
> expected, it has the issue.
>
> So I think it is also worth having this to stop this happening elsewhere:
>
> ------>8-------
>
> Subject: [PATCH] scsi: core: Cap initial sdev queue depth at Shost.can_queue
>
> Function sdev_store_queue_depth() enforces that the sdev queue depth cannot
> exceed Shost.can_queue.
>
> However, the LLDD may still set cmd_per_lun > can_queue, which would lead to
> an initial sdev queue depth greater than can_queue.
>
> Stop this happened by capping initial sdev queue depth at can_queue.
>
> <insert credits>
> Signed-off-by: John Garry <john.garry@huawei.com>
>
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 9af50e6f94c4..fec6c17ff37c 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -218,6 +218,7 @@ static struct scsi_device *scsi_alloc_sdev(struct
> scsi_target *starget,
> struct scsi_device *sdev;
> int display_failure_msg = 1, ret;
> struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
> + int depth;
>
> sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
> GFP_KERNEL);
> @@ -276,8 +277,13 @@ static struct scsi_device *scsi_alloc_sdev(struct
> scsi_target *starget,
> WARN_ON_ONCE(!blk_get_queue(sdev->request_queue));
> sdev->request_queue->queuedata = sdev;
>
> - scsi_change_queue_depth(sdev, sdev->host->cmd_per_lun ?
> - sdev->host->cmd_per_lun : 1);
> + if (sdev->host->cmd_per_lun)
> + depth = min_t(int, sdev->host->cmd_per_lun,
> + sdev->host->can_queue);
> + else
> + depth = 1;
> +
> + scsi_change_queue_depth(sdev, depth);
'cmd_per_lun' should have been set as correct from the beginning instead
of capping it for changing queue depth:
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 697c09ef259b..0d9954eabbb8 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -414,7 +414,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
shost->can_queue = sht->can_queue;
shost->sg_tablesize = sht->sg_tablesize;
shost->sg_prot_tablesize = sht->sg_prot_tablesize;
- shost->cmd_per_lun = sht->cmd_per_lun;
+ shost->cmd_per_lun = min_t(int, sht->cmd_per_lun, shost->can_queue);
shost->no_write_same = sht->no_write_same;
shost->host_tagset = sht->host_tagset;
Thanks,
Ming
next prev parent reply other threads:[~2021-04-16 1:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 1:50 [PATCH] scsi_debug: fix cmd_per_lun, set to max_queue Douglas Gilbert
2021-04-15 9:15 ` John Garry
2021-04-16 1:46 ` Ming Lei [this message]
2021-04-16 8:17 ` John Garry
2021-04-16 8:26 ` Ming Lei
2021-04-16 8:33 ` John Garry
2021-04-16 8:50 ` Ming Lei
2021-04-16 9:07 ` John Garry
2021-04-16 9:12 ` John Garry
2021-04-16 16:32 ` Douglas Gilbert
2021-04-29 13:17 ` John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YHjsXaVJJsQXwEPW@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=dgilbert@interlog.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=john.garry@huawei.com \
--cc=kashyap.desai@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox