Re: [PATCH] scsi: storvsc: set max_segment_size as UINT_MAX explicitly

Ming Lei
2025-06-17T07:25:39Z

On Tue, Jun 17, 2025 at 07:02:40AM +0200, Christoph Hellwig wrote:
> Please try this proper fix instead:
>
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index e021f1106bea..09f5fb5b2fb1 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -473,7 +473,9 @@ struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, int priv
> else
> shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
>
> - if (sht->max_segment_size)
> + if (sht->virt_boundary_mask)
> + shost->virt_boundary_mask = sht->virt_boundary_mask;
> + else if (sht->max_segment_size)
> shost->max_segment_size = sht->max_segment_size;
> else
> shost->max_segment_size = BLK_MAX_SEGMENT_SIZE;

This way works, but I prefer to set it explicitly in driver, instead of
making block layer more fragile to deal with def ->max_segment_size
if ->virt_boundary_mask is defined

- for low level driver, if ->virt_boundary_mask is defined, ->max_segment_size
should be UINT_MAX obviously since it implies single `virt segment`.
Setting UINT_MAX in driver has document benefit too.

- for logical block device(md, dm, ...), both ->virt_boundary_mask and
->max_segment_size may be set, and it is fine since logical block device
driver needn't to deal with sg

Thanks,
Ming