All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: lv.mengzhao@zte.com.cn
Cc: mst@redhat.com, kwolf@redhat.com, hreitz@redhat.com,
	qemu-devel@nongnu.org, hu.jian@zte.com.cn
Subject: Re: [PATCH] virtio-blk: don't start dataplane during the stop of dataplane
Date: Tue, 17 Oct 2023 10:03:46 -0400	[thread overview]
Message-ID: <20231017140346.GA216511@fedora> (raw)
In-Reply-To: <202310111414266586398@zte.com.cn>

[-- Attachment #1: Type: text/plain, Size: 2229 bytes --]

On Wed, Oct 11, 2023 at 02:14:26PM +0800, lv.mengzhao@zte.com.cn wrote:
> From: hujian <hu.jian@zte.com.cn>
> 
> During the stop of dataplane for virtio-blk, virtio_bus_cleanup_host_notifier() is be
> called to clean up notifier at the end, if polled ioeventfd, virtio_blk_handle_output()
> is used to handle io request. But due to s->dataplane_disabled is false, it will be
> returned directly, which drops io request.
> Backtrace:
> ->virtio_blk_data_plane_stop
>   ->virtio_bus_cleanup_host_notifier
>     ->virtio_queue_host_notifier_read
>       ->virtio_queue_notify_vq
>         ->vq->handle_output
>           ->virtio_blk_handle_output
>             ->if (s->dataplane  && !s->dataplane_stoped)
>               ->if (!s->dataplane_disabled)
>                 ->return *
>             ->virtio_blk_handle_output_do
> The above problem can occur when using "virsh reset" cmdline to reset guest, while
> guest does io.
> To fix this problem, don't try to start dataplane if s->stopping is true, and io would
> be handled by virtio_blk_handle_vq().
> 
> Signed-off-by: hujian <hu.jian@zte.com.cn>
> ---
>  hw/block/virtio-blk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

I have dropped this patch again after Fiona pointed out it does not
compile and Kevin noticed that handling requests from the main loop
thread while the I/O is still being processed in the IOThread is going
to cause thread-safety issues.

Can you explain the problem you are seeing in more detail? You run
"virsh reset" while the guest is doing I/O. Then what happens?

Stefan

> 
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 39e7f23..c2d5938 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -1166,7 +1166,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
>  {
>      VirtIOBlock *s = (VirtIOBlock *)vdev;
> 
> -    if (s->dataplane && !s->dataplane_started) {
> +    if (s->dataplane && !s->dataplane_started && !s->stopping) {
>          /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
>           * dataplane here instead of waiting for .set_status().
>           */
> --
> 1.8.3.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2023-10-17 14:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  6:14 [PATCH] virtio-blk: don't start dataplane during the stop of dataplane lv.mengzhao
2023-10-16 19:39 ` Stefan Hajnoczi
2023-10-17 14:03 ` Stefan Hajnoczi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-10-11  7:17 lv.mengzhao
2023-10-11  3:37 hujian

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=20231017140346.GA216511@fedora \
    --to=stefanha@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=hu.jian@zte.com.cn \
    --cc=kwolf@redhat.com \
    --cc=lv.mengzhao@zte.com.cn \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.