[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/41] qemu-img: conditionally zero out target on con
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 17/41] qemu-img: conditionally zero out target on convert |
Date: |
Fri, 29 Nov 2013 17:45:32 +0100 |
From: Peter Lieven <address@hidden>
If the target has_zero_init = 0, but supports efficiently
writing zeroes by unmapping we call bdrv_make_zero to
avoid fully allocating the target. This currently works
only for iscsi. It can be extended to raw with
BLKDISCARDZEROES for example.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
qemu-img.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
index cc3fed7..dc0c2f0 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1355,7 +1355,7 @@ static int img_convert(int argc, char **argv)
}
}
- flags = BDRV_O_RDWR;
+ flags = min_sparse ? (BDRV_O_RDWR | BDRV_O_UNMAP) : BDRV_O_RDWR;
ret = bdrv_parse_cache_flags(cache, &flags);
if (ret < 0) {
error_report("Invalid cache option: %s", cache);
@@ -1471,6 +1471,14 @@ static int img_convert(int argc, char **argv)
} else {
int has_zero_init = min_sparse ? bdrv_has_zero_init(out_bs) : 0;
+ if (!has_zero_init && bdrv_can_write_zeroes_with_unmap(out_bs)) {
+ ret = bdrv_make_zero(out_bs, BDRV_REQ_MAY_UNMAP);
+ if (ret < 0) {
+ goto out;
+ }
+ has_zero_init = 1;
+ }
+
sector_num = 0; // total number of sectors converted so far
nb_sectors = total_sectors - sector_num;
if (nb_sectors != 0) {
--
1.8.1.4
- [Qemu-devel] [PULL 05/41] block: add wrappers for logical block provisioning information, (continued)
- [Qemu-devel] [PULL 05/41] block: add wrappers for logical block provisioning information, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 08/41] block/raw: copy BlockLimits on raw_open, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 09/41] block: honour BlockLimits in bdrv_co_do_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 10/41] block: honour BlockLimits in bdrv_co_discard, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 11/41] iscsi: set limits in BlockDriverState, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 12/41] iscsi: simplify iscsi_co_discard, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 13/41] iscsi: add bdrv_co_write_zeroes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 14/41] block: introduce bdrv_make_zero, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 15/41] block/get_block_status: fix BDRV_BLOCK_ZERO for unallocated blocks, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 16/41] qemu-img: add support for fully allocated images, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 17/41] qemu-img: conditionally zero out target on convert,
Kevin Wolf <=
- [Qemu-devel] [PULL 18/41] util/error: Save errno from clobbering, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 19/41] Test coroutine execution order, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 20/41] sheepdog: implement .bdrv_get_allocated_file_size, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 21/41] block/stream: Don't stream unbacked devices, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 22/41] block: per caller dirty bitmap, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 24/41] COW: Speed up writes, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 25/41] COW: Extend checking allocated bits to beyond one sector, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 26/41] MAINTAINERS: add sheepdog development mailing list, Kevin Wolf, 2013/11/29
- [Qemu-devel] [PULL 23/41] qapi: Change BlockDirtyInfo to list, Kevin Wolf, 2013/11/29