[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/16] virtio-blk: Use ioeventfd_attach in start_ioeventfd
From: |
Kevin Wolf |
Subject: |
[PULL 15/16] virtio-blk: Use ioeventfd_attach in start_ioeventfd |
Date: |
Wed, 7 Feb 2024 22:56:05 +0100 |
From: Hanna Czenczek <hreitz@redhat.com>
Commit d3f6f294aeadd5f88caf0155e4360808c95b3146 ("virtio-blk: always set
ioeventfd during startup") has made virtio_blk_start_ioeventfd() always
kick the virtqueue (set the ioeventfd), regardless of whether the BB is
drained. That is no longer necessary, because attaching the host
notifier will now set the ioeventfd, too; this happens either
immediately right here in virtio_blk_start_ioeventfd(), or later when
the drain ends, in virtio_blk_ioeventfd_attach().
With event_notifier_set() removed, the code becomes the same as the one
in virtio_blk_ioeventfd_attach(), so we can reuse that function.
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
Message-ID: <20240202153158.788922-4-hreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/block/virtio-blk.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index bda5c117d4..4ca5e632ea 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -37,6 +37,8 @@
#include "hw/virtio/virtio-blk-common.h"
#include "qemu/coroutine.h"
+static void virtio_blk_ioeventfd_attach(VirtIOBlock *s);
+
static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
VirtIOBlockReq *req)
{
@@ -1847,17 +1849,14 @@ static int virtio_blk_start_ioeventfd(VirtIODevice
*vdev)
s->ioeventfd_started = true;
smp_wmb(); /* paired with aio_notify_accept() on the read side */
- /* Get this show started by hooking up our callbacks */
- for (i = 0; i < nvqs; i++) {
- VirtQueue *vq = virtio_get_queue(vdev, i);
- AioContext *ctx = s->vq_aio_context[i];
-
- /* Kick right away to begin processing requests already in vring */
- event_notifier_set(virtio_queue_get_host_notifier(vq));
-
- if (!blk_in_drain(s->conf.conf.blk)) {
- virtio_queue_aio_attach_host_notifier(vq, ctx);
- }
+ /*
+ * Get this show started by hooking up our callbacks. If drained now,
+ * virtio_blk_drained_end() will do this later.
+ * Attaching the notifier also kicks the virtqueues, processing any
requests
+ * they may already have.
+ */
+ if (!blk_in_drain(s->conf.conf.blk)) {
+ virtio_blk_ioeventfd_attach(s);
}
return 0;
--
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 07/16] scsi: Await request purging, Kevin Wolf, 2024/02/07
- [PULL 10/16] virtio-blk: do not use C99 mixed declarations, Kevin Wolf, 2024/02/07
- [PULL 08/16] iotests: fix leak of tmpdir in dry-run mode, Kevin Wolf, 2024/02/07
- [PULL 11/16] scsi: Don't ignore most usb-storage properties, Kevin Wolf, 2024/02/07
- [PULL 13/16] virtio-scsi: Attach event vq notifier with no_poll, Kevin Wolf, 2024/02/07
- [PULL 09/16] iotests: give tempdir an identifying name, Kevin Wolf, 2024/02/07
- [PULL 12/16] blkio: Respect memory-alignment for bounce buffer allocations, Kevin Wolf, 2024/02/07
- [PULL 16/16] virtio-blk: avoid using ioeventfd state in irqfd conditional, 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 <=
- Re: [PULL 00/16] Block layer patches, Peter Maydell, 2024/02/09