Re: [PATCH] virtio_blk: make virtio blks as non-rotational devices

From: Stefan Hajnoczi
Date: Mon Mar 29 2021 - 12:24:31 EST


On Fri, Mar 26, 2021 at 11:39:13AM +0800, Sochin Jiang wrote:
> This confuses some users seeing one rotational block device
> in the guest(/sys/block/vdx/queue/rotational), let's make
> virtio blks as virtual block devices, just like xen blks,
> and as we known, QUEUE_FLAG_VIRT is defined as QUEUE_FLAG_NONROT
> actually. See also rbd and nbd block devices.
>
> Signed-off-by: Sochin Jiang <jiangxiaoqing.sochin@xxxxxxxxxxxxx>
> ---
> drivers/block/virtio_blk.c | 1 +
> 1 file changed, 1 insertion(+)

I would like to make this change because it seems consistent and often
the disk really is non-rotational. However, a justification and
performance results are needed especially since this has been reverted
previously. Please see commit f8b12e513b953aebf30f8ff7d2de9be7e024dbbe
("virtio_blk: revert QUEUE_FLAG_VIRT addition").

That was in 2009, so maybe things have changed now. Please explain what
has changed in the commit description.

This flag can affect performance. Please include performance data.

> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index b9fa3ef5b57c..31a978a4dab5 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -822,6 +822,7 @@ static int virtblk_probe(struct virtio_device *vdev)
> max_size = min(max_size, v);
>
> blk_queue_max_segment_size(q, max_size);
> + blk_queue_flag_set(QUEUE_FLAG_VIRT, q);
>
> /* Host can optionally specify the block size of the device */
> err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
> --
> 2.11.0
>

Attachment: signature.asc
Description: PGP signature