From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Max Reitz <mreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] qcow2: Flush image after creation
Date: Mon, 28 Oct 2013 16:10:48 +0100 [thread overview]
Message-ID: <20131028151048.GF2890@irqsave.net> (raw)
In-Reply-To: <1382639706-7404-1-git-send-email-mreitz@redhat.com>
Le Thursday 24 Oct 2013 à 20:35:06 (+0200), Max Reitz a écrit :
> Opening the qcow2 image with BDRV_O_NO_FLUSH prevents any flushes during
> the image creation. This means that the image has not yet been flushed
> to disk when qemu-img create exits. This flush is delayed until the next
> operation on the image involving opening it without BDRV_O_NO_FLUSH and
> closing (or directly flushing) it. For large images and/or images with a
> small cluster size and preallocated metadata, this flush may take a
> significant amount of time and may occur unexpectedly.
>
> Reopening the image without BDRV_O_NO_FLUSH right before the end of
> qcow2_create2() results in hoisting the potentially costly flush into
> the image creation, which is expected to take some time (whereas
> successive image operations may be not).
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
> v2:
> - implemented Kevin's remarks:
> - left ret = 0; in the code
> - added goto out; in error handling of bdrv_open
> - implemented Eric's remarks:
> - changed indentation of bdrv_open arguments
> - s/preponing/hoisting/ in the commit message
> ---
> block/qcow2.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 01269f9..6e5d98d 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1584,6 +1584,16 @@ static int qcow2_create2(const char *filename, int64_t total_size,
> }
> }
>
> + bdrv_close(bs);
> +
> + /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
> + ret = bdrv_open(bs, filename, NULL,
> + BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
> + if (error_is_set(&local_err)) {
> + error_propagate(errp, local_err);
> + goto out;
> + }
> +
> ret = 0;
> out:
> bdrv_unref(bs);
> --
> 1.8.3.1
>
>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
prev parent reply other threads:[~2013-10-28 15:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 18:35 [Qemu-devel] [PATCH v2] qcow2: Flush image after creation Max Reitz
2013-10-25 9:15 ` Kevin Wolf
2013-10-28 15:10 ` Benoît Canet [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=20131028151048.GF2890@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@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).