* [Qemu-devel] [PATCH v5] qemu-img: check block status of backing file when converting.
@ 2016-04-27 16:04 Ren Kimura
2016-04-27 16:31 ` Max Reitz
0 siblings, 1 reply; 2+ messages in thread
From: Ren Kimura @ 2016-04-27 16:04 UTC (permalink / raw)
To: mreitz; +Cc: kwolf, qemu-block, qemu-devel
When converting images, check the block status of its backing file chain
to avoid needlessly reading zeros.
Signed-off-by: Ren Kimura <rkx1209dev@gmail.com>
---
qemu-img.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 1697762..cb72f14 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1478,10 +1478,21 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num)
} else if (!s->target_has_backing) {
/* Without a target backing file we must copy over the contents of
* the backing file as well. */
- /* TODO Check block status of the backing file chain to avoid
+ /* Check block status of the backing file chain to avoid
* needlessly reading zeroes and limiting the iteration to the
* buffer size */
- s->status = BLK_DATA;
+ ret = bdrv_get_block_status_above(blk_bs(s->src[s->src_cur]), NULL,
+ sector_num - s->src_cur_offset,
+ n, &n, &file);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (ret & BDRV_BLOCK_ZERO) {
+ s->status = BLK_ZERO;
+ } else {
+ s->status = BLK_DATA;
+ }
} else {
s->status = BLK_BACKING_FILE;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v5] qemu-img: check block status of backing file when converting.
2016-04-27 16:04 [Qemu-devel] [PATCH v5] qemu-img: check block status of backing file when converting Ren Kimura
@ 2016-04-27 16:31 ` Max Reitz
0 siblings, 0 replies; 2+ messages in thread
From: Max Reitz @ 2016-04-27 16:31 UTC (permalink / raw)
To: Ren Kimura; +Cc: kwolf, qemu-block, qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 473 bytes --]
On 27.04.2016 18:04, Ren Kimura wrote:
> When converting images, check the block status of its backing file chain
> to avoid needlessly reading zeros.
>
> Signed-off-by: Ren Kimura <rkx1209dev@gmail.com>
> ---
> qemu-img.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
Thank you, I applied the patch to my block-next tree for inclusion into
qemu after the 2.6 release:
https://github.com/XanClic/qemu/commits/block-next
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-27 16:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-27 16:04 [Qemu-devel] [PATCH v5] qemu-img: check block status of backing file when converting Ren Kimura
2016-04-27 16:31 ` Max Reitz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.