[PATCH 12/15] virtio_blk: pass queue_limits to blk_mq_alloc_disk
John Garry
john.g.garry at oracle.com
Fri Jun 28 07:25:02 PDT 2024
On 22/01/2024 17:36, Christoph Hellwig wrote:> max_dma_size =
virtio_max_dma_size(vdev);
> max_size = max_dma_size > U32_MAX ? U32_MAX : max_dma_size;
> @@ -1288,7 +1283,7 @@ static int virtblk_read_limits(struct virtio_blk *vblk)
> if (!err)
> max_size = min(max_size, v);
>
> - blk_queue_max_segment_size(q, max_size);
> + 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,
> @@ -1303,35 +1298,34 @@ static int virtblk_read_limits(struct virtio_blk *vblk)
> return err;
> }
>
> - blk_queue_logical_block_size(q, blk_size);
> + lim->logical_block_size = blk_size;
> } else
> - blk_size = queue_logical_block_size(q);
> + blk_size = lim->logical_block_size;
>
> /* Use topology information if available */
> err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
> struct virtio_blk_config, physical_block_exp,
> &physical_block_exp);
> if (!err && physical_block_exp)
> - blk_queue_physical_block_size(q,
> - blk_size * (1 << physical_block_exp));
> + lim->physical_block_size = blk_size * (1 << physical_block_exp);
>
> err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY,
> struct virtio_blk_config, alignment_offset,
> &alignment_offset);
I think that we might need a change like the following change after this:
----8<----
[PATCH] virtio_blk: Fix default logical block size
If we fail to read a logical block size in virtblk_read_limits() ->
virtio_cread_feature(), then we default to what is in
lim->logical_block_size, but that would be 0.
We can deal with lim->logical_block_size = 0 later in the
blk_mq_alloc_disk(), but the subsequent code in virtblk_read_limits()
cannot, so give a default of SECTOR_SIZE.
Signed-off-by: John Garry <john.g.garry at oracle.com>
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 6c64a67ab9c9..d60d805523d2 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -1453,6 +1453,7 @@ static int virtblk_probe(struct virtio_device *vdev)
struct virtio_blk *vblk;
struct queue_limits lim = {
.features = BLK_FEAT_ROTATIONAL,
+ .logical_block_size = SECTOR_SIZE,
};
int err, index;
unsigned int queue_depth;
---->8----
Look ok?
More information about the Linux-nvme
mailing list