RE: [PATCH v1] scsi: storvsc: Cap cmd_per_lun at can_queue

From: Michael Kelley
Date: Mon Mar 08 2021 - 09:38:43 EST


From: Melanie Plageman (Microsoft) <melanieplageman@xxxxxxxxx> Sent: Friday, March 5, 2021 3:22 PM
>
> The scsi_device->queue_depth is set to Scsi_Host->cmd_per_lun during
> allocation.
>
> Cap cmd_per_lun at can_queue to avoid dispatch errors.
>
> Signed-off-by: Melanie Plageman (Microsoft) <melanieplageman@xxxxxxxxx>
> ---
> drivers/scsi/storvsc_drv.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 6bc5453cea8a..d7953a6e00e6 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1946,6 +1946,8 @@ static int storvsc_probe(struct hv_device *device,
> (max_sub_channels + 1) *
> (100 - ring_avail_percent_lowater) / 100;
>
> + scsi_driver.cmd_per_lun = min_t(u32, scsi_driver.cmd_per_lun, scsi_driver.can_queue);
> +

I'm not sure what you mean by "avoid dispatch errors". Can you elaborate?
Be aware that the calculation of "can_queue" in this driver is somewhat
flawed -- it should not be based on the size of the ring buffer, but instead on
the maximum number of requests Hyper-V will queue. And even then,
can_queue doesn't provide the cap you might expect because the blk-mq layer
allocates can_queue tags for each HW queue, not as a total.

I agree that the cmd_per_lun setting is also too big, but we should fix that in
the context of getting all of these different settings working together correctly,
and not piecemeal.

Michael

> host = scsi_host_alloc(&scsi_driver,
> sizeof(struct hv_host_device));
> if (!host)
> --
> 2.20.1