From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
Sergio Lopez <slp@redhat.com>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>
Subject: Re: [PATCH] virtio-blk: simplify virtio_blk_dma_restart_cb()
Date: Thu, 10 Nov 2022 10:03:21 -0500 [thread overview]
Message-ID: <Y20SucmGAnCu3Epl@fedora> (raw)
In-Reply-To: <20221110072742-mutt-send-email-mst@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2158 bytes --]
On Thu, Nov 10, 2022 at 07:27:59AM -0500, Michael S. Tsirkin wrote:
> On Wed, Nov 02, 2022 at 02:23:37PM -0400, Stefan Hajnoczi wrote:
> > virtio_blk_dma_restart_cb() is tricky because the BH must deal with
> > virtio_blk_data_plane_start()/virtio_blk_data_plane_stop() being called.
> >
> > There are two issues with the code:
> >
> > 1. virtio_blk_realize() should use qdev_add_vm_change_state_handler()
> > instead of qemu_add_vm_change_state_handler(). This ensures the
> > ordering with virtio_init()'s vm change state handler that calls
> > virtio_blk_data_plane_start()/virtio_blk_data_plane_stop() is
> > well-defined. Then blk's AioContext is guaranteed to be up-to-date in
> > virtio_blk_dma_restart_cb() and it's no longer necessary to have a
> > special case for virtio_blk_data_plane_start().
> >
> > 2. Only blk_drain() waits for virtio_blk_dma_restart_cb()'s
> > blk_inc_in_flight() to be decremented. The bdrv_drain() family of
> > functions do not wait for BlockBackend's in_flight counter to reach
> > zero. virtio_blk_data_plane_stop() relies on blk_set_aio_context()'s
> > implicit drain, but that's a bdrv_drain() and not a blk_drain().
> > Note that virtio_blk_reset() already correctly relies on blk_drain().
> > If virtio_blk_data_plane_stop() switches to blk_drain() then we can
> > properly wait for pending virtio_blk_dma_restart_bh() calls.
> >
> > Once these issues are taken care of the code becomes simpler. This
> > change is in preparation for multiple IOThreads in virtio-blk where we
> > need to clean up the multi-threading behavior.
> >
> > I ran the reproducer from commit 49b44549ace7 ("virtio-blk: On restart,
> > process queued requests in the proper context") to check that there is
> > no regression.
> >
> > Cc: Sergio Lopez <slp@redhat.com>
> > Cc: Kevin Wolf <kwolf@redhat.com>
> > Cc: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
> block tree I presume?
Thanks, merged into my block-next tree.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2022-11-10 15:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 18:23 [PATCH] virtio-blk: simplify virtio_blk_dma_restart_cb() Stefan Hajnoczi
2022-11-02 23:54 ` Michael S. Tsirkin
2022-11-03 16:35 ` Emanuele Giuseppe Esposito
2022-11-10 12:27 ` Michael S. Tsirkin
2022-11-10 15:03 ` Stefan Hajnoczi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y20SucmGAnCu3Epl@fedora \
--to=stefanha@redhat.com \
--cc=eesposit@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=slp@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.