提交 263a6f4c 编写于 作者: R Ren Kimura 提交者: Max Reitz

qemu-img: check block status of backing file when converting.

When converting images, check the block status of its backing file chain
to avoid needlessly reading zeros.
Signed-off-by: NRen Kimura <rkx1209dev@gmail.com>
Message-id: 1461773098-20356-1-git-send-email-rkx1209dev@gmail.com
Signed-off-by: NMax Reitz <mreitz@redhat.com>
上级 9036e87c
...@@ -1475,10 +1475,21 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) ...@@ -1475,10 +1475,21 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num)
} else if (!s->target_has_backing) { } else if (!s->target_has_backing) {
/* Without a target backing file we must copy over the contents of /* Without a target backing file we must copy over the contents of
* the backing file as well. */ * 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 * needlessly reading zeroes and limiting the iteration to the
* buffer size */ * 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 { } else {
s->status = BLK_BACKING_FILE; s->status = BLK_BACKING_FILE;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册