[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qcow2: Flush image after creation
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qcow2: Flush image after creation |
Date: |
Thu, 24 Oct 2013 11:04:43 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
On 10/23/2013 08:40 PM, Max Reitz wrote:
> 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 preponing the potentially costly flush into
s/preponing/hoisting/
> the image creation, which is expected to take some time (whereas
> successive image operations may be not).
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
Reviewed-by: Eric Blake <address@hidden>
> - ret = 0;
> + 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);
I would probably have indented as:
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB,
drv, &local_err);
but it's trivial enough that I'm also fine with your choice.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature