[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/16] virtio-blk: avoid using ioeventfd state in irqfd conditiona
From: |
Kevin Wolf |
Subject: |
[PULL 16/16] virtio-blk: avoid using ioeventfd state in irqfd conditional |
Date: |
Wed, 7 Feb 2024 22:56:06 +0100 |
From: Stefan Hajnoczi <stefanha@redhat.com>
Requests that complete in an IOThread use irqfd to notify the guest
while requests that complete in the main loop thread use the traditional
qdev irq code path. The reason for this conditional is that the irq code
path requires the BQL:
if (s->ioeventfd_started && !s->ioeventfd_disabled) {
virtio_notify_irqfd(vdev, req->vq);
} else {
virtio_notify(vdev, req->vq);
}
There is a corner case where the conditional invokes the irq code path
instead of the irqfd code path:
static void virtio_blk_stop_ioeventfd(VirtIODevice *vdev)
{
...
/*
* Set ->ioeventfd_started to false before draining so that host notifiers
* are not detached/attached anymore.
*/
s->ioeventfd_started = false;
/* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete */
blk_drain(s->conf.conf.blk);
During blk_drain() the conditional produces the wrong result because
ioeventfd_started is false.
Use qemu_in_iothread() instead of checking the ioeventfd state.
Buglink: https://issues.redhat.com/browse/RHEL-15394
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20240122172625.415386-1-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/block/virtio-blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 4ca5e632ea..738cb2ac36 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -66,7 +66,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req,
unsigned char status)
iov_discard_undo(&req->inhdr_undo);
iov_discard_undo(&req->outhdr_undo);
virtqueue_push(req->vq, &req->elem, req->in_len);
- if (s->ioeventfd_started && !s->ioeventfd_disabled) {
+ if (qemu_in_iothread()) {
virtio_notify_irqfd(vdev, req->vq);
} else {
virtio_notify(vdev, req->vq);
--
2.43.0
- [PULL 03/16] virtio-blk: add vq_rq[] bounds check in virtio_blk_dma_restart_cb(), (continued)
- [PULL 03/16] virtio-blk: add vq_rq[] bounds check in virtio_blk_dma_restart_cb(), Kevin Wolf, 2024/02/07
- [PULL 06/16] block-backend: Allow concurrent context changes, Kevin Wolf, 2024/02/07
- [PULL 08/16] iotests: fix leak of tmpdir in dry-run mode, Kevin Wolf, 2024/02/07
- [PULL 09/16] iotests: give tempdir an identifying name, Kevin Wolf, 2024/02/07
- [PULL 10/16] virtio-blk: do not use C99 mixed declarations, Kevin Wolf, 2024/02/07
- [PULL 11/16] scsi: Don't ignore most usb-storage properties, Kevin Wolf, 2024/02/07
- [PULL 12/16] blkio: Respect memory-alignment for bounce buffer allocations, Kevin Wolf, 2024/02/07
- [PULL 13/16] virtio-scsi: Attach event vq notifier with no_poll, Kevin Wolf, 2024/02/07
- [PULL 14/16] virtio: Re-enable notifications after drain, Kevin Wolf, 2024/02/07
- [PULL 15/16] virtio-blk: Use ioeventfd_attach in start_ioeventfd, Kevin Wolf, 2024/02/07
- [PULL 16/16] virtio-blk: avoid using ioeventfd state in irqfd conditional,
Kevin Wolf <=
- Re: [PULL 00/16] Block layer patches, Peter Maydell, 2024/02/09