Re: [PATCH v2] virtio-blk: clamp max_segments when indirect descriptors are disabled
Stefan Hajnoczi <[email protected]>
| Newsgroups | org.kernel.vger.linux-block,dev.linux.lists.virtualization,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260817172802.GD143460@fedora> |
On Mon, Aug 17, 2026 at 03:42:02PM +0200, Sergii Ushakov wrote: > When VIRTIO_RING_F_INDIRECT_DESC is not negotiated by the host, every > scatter-gather segment in a request must consume a physical slot in > the virtqueue ring. > > If the host does not advertise VIRTIO_BLK_F_SEG_MAX and provides a small > virtqueue (e.g. 128 descriptors on QNX Hypervisor), the block layer > defaults max_segments to BLK_MAX_SEGMENTS (1024). When a multi-page > compound bio arrives from the page cache, virtqueue_add_split() rejects > the request with -ENOSPC and triggers: > > WARNING: at drivers/virtio/virtio_ring.c:1493 virtqueue_add+... > WARN_ON_ONCE(total_sg > vq->split.vring.num && !vq->indirect); > > This permanently wedges the blk-mq queue and blocks all subsequent disk > I/O in uninterruptible sleep (D state). > > Automatically clamp sg_elems to (ring_size - 2) when indirect > descriptors are disabled. > > Signed-off-by: Sergii Ushakov <[email protected]> > --- > v1 -> v2: > - Drop max_segments module parameter and rely solely on automatic clamping > when indirect descriptors are disabled (suggested by Christoph Hellwig). > - Guard (ring_size - 2) calculation with ring_size > 2 to prevent underflow. > - Update commit description accordingly. > > drivers/block/virtio_blk.c | 7 +++++++ > 1 file changed, 7 insertions(+) Reviewed-by: Stefan Hajnoczi <[email protected]>
signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmqDRKIACgkQnKSrs4Gr c8j88gf/Sw0C0gWMfRiNdoiWekEA9OgWGflcucM8bR9ada3wuc3yiLwvsQtyft06 p6OOINs4QC/eGZimiVd6paoj0qOcaJOjx4xjyz44uHbpwlAVJhBtwDU/r3Ti7Y5/ pUAY+LQ+jUcVJshQizkXJbXGrO9T/vOoUwJRWLSiK4s2vApbaj1Ub7kHfcNPyg0E u0Z+ZtmVd9hoGpC37LV7Aur6P8NHXailJ7r7wj+wlr8OH5WgmY0QqkM1hlohQjna RW62m7FQLgLZcbPXoHC3Musrnya0fZTKQOxpnLKePNMBp1IMoqICTfVwSoWlHedz VbZU+RZSlWJvDS6haBKLDXCzCMd5lg== =iyx9 -----END PGP SIGNATURE-----