diff mbox series

[v2,4/5] virtio_blk: Don't bother validating blocksize

Message ID 20240708091651.177447-5-john.g.garry@oracle.com (mailing list archive)
State New, archived
Headers show
Series Validate logical block size in blk_validate_limits() | expand

Commit Message

John Garry July 8, 2024, 9:16 a.m. UTC
The block queue limits validation does this for us now.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 drivers/block/virtio_blk.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

Damien Le Moal July 9, 2024, 5:39 a.m. UTC | #1
On 7/8/24 18:16, John Garry wrote:
> The block queue limits validation does this for us now.
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>  drivers/block/virtio_blk.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index f11b0c3b2625..e3147a611151 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -1289,18 +1289,9 @@ static int virtblk_read_limits(struct virtio_blk *vblk,
>  	lim->max_segment_size = max_size;
>  
>  	/* Host can optionally specify the block size of the device */
> -	err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
> +	virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
>  				   struct virtio_blk_config, blk_size,
>  				   &lim->logical_block_size);

I really wonder why this does not check that the VIRTIO_BLK_F_BLK_SIZE feature
exists... But that is not the fault of this patch :)

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

> -	if (!err) {
> -		err = blk_validate_block_size(lim->logical_block_size);
> -		if (err) {
> -			dev_err(&vdev->dev,
> -				"virtio_blk: invalid block size: 0x%x\n",
> -				lim->logical_block_size);
> -			return err;
> -		}
> -	}
>  
>  	/* Use topology information if available */
>  	err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
diff mbox series

Patch

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index f11b0c3b2625..e3147a611151 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -1289,18 +1289,9 @@  static int virtblk_read_limits(struct virtio_blk *vblk,
 	lim->max_segment_size = max_size;
 
 	/* Host can optionally specify the block size of the device */
-	err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
+	virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
 				   struct virtio_blk_config, blk_size,
 				   &lim->logical_block_size);
-	if (!err) {
-		err = blk_validate_block_size(lim->logical_block_size);
-		if (err) {
-			dev_err(&vdev->dev,
-				"virtio_blk: invalid block size: 0x%x\n",
-				lim->logical_block_size);
-			return err;
-		}
-	}
 
 	/* Use topology information if available */
 	err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,