Re: [PATCH 1/1] virtio-blk: Add description for blk_size field

Stefan Hajnoczi <[email protected]> Wed, 2 Oct 2024 09:42:17 -0400
Newsgroups dev.linux.lists.virtio-dev,dev.linux.lists.virtualization
Message-ID <[email protected]>
On Mon, Sep 30, 2024 at 06:45:23PM -0700, Daniel Verkamp wrote:
> From my point of view, it would be fine to clarify a few things:
> - blk_size should (not must) be the logical block size of the
> underlying storage device
> - data should (not must) be a multiple of blk_size for best performance
> 
> And maybe:
> - devices may choose to return IOERR if a driver submits an I/O
> request that does not conform to the above recommendations (but this
> conflicts with the "performance"-related wording that exists now)

QEMU's virtio-blk implementation returns IOERR when the driver submits
VIRTIO_BLK_T_IN/VIRTIO_BLK_T_OUT requests that are not aligned to the
logical block size:
https://gitlab.com/qemu-project/qemu/-/blob/master/hw/block/virtio-blk.c#L367

Although I interpret the virtio-blk spec in the same way as you
(blk_size is just a hint for optimal performance), I guess in practice
drivers align requests to blk_size.

Adding a note that devices may return IOERR is worthwhile. It will tell
driver authors not to expect device implementations to accept misaligned
requests.

Stefan
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmb9TbkACgkQnKSrs4Gr
c8hVXwf/XRz+4IQYbND7w3zKaqA2UAKcd0tOkCNArVI/HjDh9w2iwGRJbpJYyfU7
5uU4pebhzlOU4jXQ1lpeYUgC5cCOa6bqb7SgGkJi1eDlgCNP1nTfSdo+6t9GfNe9
yo7Ue+E/2GsyyPDRJOheDuZ9J4CuZke3nSegR9+HwoVYYrPcbN4OaW53KwAtA45v
epkUJwfkKgqvPtwH98Y3bz9ZH/6t/AnC86OMrmUcMYnIFQAGO3kkY56uUWpdy7AL
bDFt3TjGf4D9EqtNPPZ2upoU0OBg0sxrmV6Fx0LUhUbZVgSA31U2DnQ+Ns32FT6h
x/kJlNxseGdYlOs4RuG5cKqACAQ5UA==
=wAnB
-----END PGP SIGNATURE-----