Re: [PATCH v2 2/2] vhost-scsi: clamp max_io_vqs module parameter

Mike Christie <[email protected]>
Newsgroups org.kernel.vger.kvm,dev.linux.lists.virtualization
Message-ID <[email protected]>
On 8/2/26 12:24 PM, Dongli Zhang wrote:
> max_io_vqs is currently validated only when a vhost-scsi device is opened.
> This allows sysfs to show values larger than the driver will actually use,
> e.g. writing 2048 succeeds even though vhost_scsi_open() later clamps it to
> VHOST_SCSI_MAX_IO_VQ. This makes the sysfs value differ from the value that
> will actually be used.
> 
> hv# echo 2048 > /sys/module/vhost_scsi/parameters/max_io_vqs
> 
> hv# cat /sys/module/vhost_scsi/parameters/max_io_vqs
> 2048
> 
> [  315.630495] Invalid max_io_vqs of 2048. Using 1024.
> 
> Keep accepting out-of-range values for compatibility, but clamp them in the
> module parameter setter and store the effective value. This preserves the
> existing behavior that invalid values do not make module loading or sysfs
> writes fail. It also makes reads report the value that will actually be
> used.
> 
> With the parameter value kept in range, remove the duplicate validation
> from vhost_scsi_open().
> 
> Signed-off-by: Dongli Zhang <[email protected]>
> ---
> v1->v2:
>   - Access vhost_scsi_max_io_vqs with READ_ONCE().
>   - Clamp out-of-range max_io_vqs values instead of rejecting them.
> 
Reviewed-by: Mike Christie <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.