[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/30] qcow2: Flush image after creation
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 07/30] qcow2: Flush image after creation |
Date: |
Thu, 31 Oct 2013 16:48:21 +0100 |
From: Max Reitz <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Benoit Canet <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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.1.4
- [Qemu-devel] [PULL v2 00/30] Block patches, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 02/30] qcow2: Restore total_sectors value in save_vmstate, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 04/30] qemu-img: add special exit code if bdrv_check is not supported, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 05/30] block/vpc: check that the image has not been truncated, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 01/30] qapi: fix documentation example, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 03/30] qcow2: Unset zero_beyond_eof in save_vmstate, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 06/30] qemu-iotests: Test for loading VM state from qcow2, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 07/30] qcow2: Flush image after creation,
Kevin Wolf <=
- [Qemu-devel] [PULL 09/30] ide-test: Check what happens with bus mastering disabled, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 10/30] tests: Multiboot mmap test case, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 11/30] block: Don't copy backing file name on error, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 08/30] exec: Fix bounce buffer allocation in address_space_map(), Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 12/30] sheepdog: explicitly set copies as type uint8_t, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 14/30] ahci: fix win7 hang on boot, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 13/30] sheepdog: pass copy_policy in the request, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 15/30] block: Disable BDRV_O_COPY_ON_READ for the backing file, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 16/30] block: Avoid unecessary drv->bdrv_getlength() calls, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 17/30] qemu-iotests: Fix 051 reference output, Kevin Wolf, 2013/10/31