qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: fix bdrv_flush() ordering in bdrv_close()
Date: Tue, 2 Jul 2013 11:38:33 +0200	[thread overview]
Message-ID: <20130702093832.GC3031@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1372678184-5008-1-git-send-email-stefanha@redhat.com>

Am 01.07.2013 um 13:29 hat Stefan Hajnoczi geschrieben:
> Since 80ccf93b we flush the block device during close.  The
> bdrv_drain_all() call should come before bdrv_flush() to ensure guest
> write requests have completed.  Otherwise we may miss pending writes
> when flushing.
> 
> However, there is still a slight change that cancelling a blockjob or
> doing bdrv_flush() might leave an I/O request running, so call
> bdrv_drain_all() again for safety as the final step.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 6c493ad..fca55b1 100644
> --- a/block.c
> +++ b/block.c
> @@ -1358,11 +1358,12 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state)
>  
>  void bdrv_close(BlockDriverState *bs)
>  {
> -    bdrv_flush(bs);
> +    bdrv_drain_all(); /* complete guest I/O */
>      if (bs->job) {
>          block_job_cancel_sync(bs->job);
>      }
> -    bdrv_drain_all();
> +    bdrv_flush(bs);
> +    bdrv_drain_all(); /* in case blockjob or flush started I/O */
>      notifier_list_notify(&bs->close_notifiers, bs);

I think we need the bdrv_drain_all() immediately before calling
bdrv_flush(), so that block job writes are flushed as well. You can
probably move the first one there, there doesn't seem to be a reason to
drain guest requests and block job requests separately.

Kevin

  reply	other threads:[~2013-07-02  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01 11:29 [Qemu-devel] [PATCH] block: fix bdrv_flush() ordering in bdrv_close() Stefan Hajnoczi
2013-07-02  9:38 ` Kevin Wolf [this message]
2013-07-02 13:29   ` 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=20130702093832.GC3031@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).