From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: stefanha@redhat.com, qemu-devel@nongnu.org,
qemu-block@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qed: fix bdrv_qed_drain
Date: Wed, 17 Feb 2016 10:57:22 +0800 [thread overview]
Message-ID: <20160217025722.GC30207@ad.usersys.redhat.com> (raw)
In-Reply-To: <1455638000-18051-1-git-send-email-pbonzini@redhat.com>
On Tue, 02/16 16:53, Paolo Bonzini wrote:
> The current implementation of bdrv_qed_drain can cause a double
> completion of a request.
>
> The problem is that bdrv_qed_drain calls qed_plug_allocating_write_reqs
> unconditionally, but this is not correct if an allocating write
> is queued. In this case, qed_unplug_allocating_write_reqs will
> restart the allocating write and possibly cause it to complete.
> The aiocb however is still in use for the L2/L1 table writes,
> and will then be completed again as soon as the table writes
> are stable.
>
> The fix is to only call qed_plug_allocating_write_reqs and
> bdrv_aio_flush (which is the same as the timer callback---the patch
> makes this explicit) only if the timer was scheduled in the first
> place. This fixes qemu-iotests test 011.
>
> Cc: qemu-stable@nongnu.org
> Cc: qemu-block@nongnu.org
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/qed.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/block/qed.c b/block/qed.c
> index 404be1e..ebba220 100644
> --- a/block/qed.c
> +++ b/block/qed.c
> @@ -380,12 +380,13 @@ static void bdrv_qed_drain(BlockDriverState *bs)
> {
> BDRVQEDState *s = bs->opaque;
>
> - /* Cancel timer and start doing I/O that were meant to happen as if it
> - * fired, that way we get bdrv_drain() taking care of the ongoing requests
> - * correctly. */
> - qed_cancel_need_check_timer(s);
> - qed_plug_allocating_write_reqs(s);
> - bdrv_aio_flush(s->bs, qed_clear_need_check, s);
> + /* Fire the timer immediately in order to start doing I/O as soon as the
> + * header is flushed.
> + */
> + if (s->need_check_timer && timer_pending(s->need_check_timer)) {
We can assert(s->need_check_timer);
> + qed_cancel_need_check_timer(s);
> + qed_need_check_timer_cb(s);
> + }
What if an allocating write is queued (the else branch case)? Its completion
will be in bdrv_drain and it could arm the need_check_timer which is wrong.
We need to drain the allocating_write_reqs queue before checking the timer.
Fam
next prev parent reply other threads:[~2016-02-17 2:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 15:53 [Qemu-devel] [PATCH] qed: fix bdrv_qed_drain Paolo Bonzini
2016-02-17 2:57 ` Fam Zheng [this message]
2016-02-17 11:28 ` Paolo Bonzini
2016-02-23 5:57 ` Fam Zheng
2016-02-23 10:43 ` Paolo Bonzini
2016-02-23 12:49 ` Fam Zheng
2016-02-23 13:54 ` Paolo Bonzini
2016-03-07 16:57 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2016-03-07 20:56 ` Stefan Hajnoczi
2016-03-07 21:22 ` [Qemu-devel] " Paolo Bonzini
2016-03-08 9:52 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-03-08 9:59 ` Kevin Wolf
2016-03-08 9:58 ` Kevin Wolf
2016-03-09 15:37 ` Stefan Hajnoczi
2016-03-07 20:57 ` Stefan Hajnoczi
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=20160217025722.GC30207@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@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.