From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 30/34] qemu-img: improve convert_iteration_sectors()
Date: Fri, 28 Apr 2017 22:33:38 +0200 [thread overview]
Message-ID: <1493411622-5343-31-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1493411622-5343-1-git-send-email-kwolf@redhat.com>
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Do not do extra call to _get_block_status()
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-id: 20170407113404.9351-1-vsementsov@virtuozzo.com
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
qemu-img.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 9eb8283..9b6e728 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1554,9 +1554,15 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num)
if (s->sector_next_status <= sector_num) {
BlockDriverState *file;
- ret = bdrv_get_block_status(blk_bs(s->src[src_cur]),
- sector_num - src_cur_offset,
- n, &n, &file);
+ if (s->target_has_backing) {
+ ret = bdrv_get_block_status(blk_bs(s->src[src_cur]),
+ sector_num - src_cur_offset,
+ n, &n, &file);
+ } else {
+ ret = bdrv_get_block_status_above(blk_bs(s->src[src_cur]), NULL,
+ sector_num - src_cur_offset,
+ n, &n, &file);
+ }
if (ret < 0) {
return ret;
}
@@ -1565,26 +1571,8 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num)
s->status = BLK_ZERO;
} else if (ret & BDRV_BLOCK_DATA) {
s->status = BLK_DATA;
- } else if (!s->target_has_backing) {
- /* Without a target backing file we must copy over the contents of
- * the backing file as well. */
- /* Check block status of the backing file chain to avoid
- * needlessly reading zeroes and limiting the iteration to the
- * buffer size */
- ret = bdrv_get_block_status_above(blk_bs(s->src[src_cur]), NULL,
- sector_num - 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;
+ s->status = s->target_has_backing ? BLK_BACKING_FILE : BLK_DATA;
}
s->sector_next_status = sector_num + n;
--
1.8.3.1
next prev parent reply other threads:[~2017-04-28 20:35 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-28 20:33 [Qemu-devel] [PULL 00/34] Block layer patches Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 01/34] block: Constify data passed by pointer to blk_name Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 02/34] file-posix: Remove unnecessary includes Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 03/34] file-win32: Remove unnecessary include Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 04/34] Revert "block/io: Comment out permission assertions" Kevin Wolf
2017-04-29 12:41 ` Paolo Bonzini
2017-04-28 20:33 ` [Qemu-devel] [PULL 05/34] qemu-img: simplify img_convert Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 06/34] migration: Call blk_resume_after_migration() for postcopy Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 07/34] qemu-iotests: Filter HMP readline escape characters Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 08/34] qemu-iotests: Test postcopy migration Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 09/34] block: An empty filename counts as no filename Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 10/34] iotests/051: Add test for empty filename Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 11/34] qemu-iotests: Remove PERL_PROG and BC_PROG Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 12/34] qemu_iotests: Remove _readlink() Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 13/34] block: Remove NULL check in bdrv_co_flush Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 14/34] iotests: Launch qemu-nbd with -e 42 Kevin Wolf
2017-04-28 22:08 ` Eric Blake
2017-05-03 14:12 ` Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 15/34] Issue a deprecation warning if the user specifies the "-hdachs" option Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 16/34] iotests: Fix typo in 026 Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 17/34] iotests: 109: Filter out "len" of failed jobs Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 18/34] block: Do not unref bs->file on error in BD's open Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 19/34] block: fix alignment calculations in bdrv_co_do_zero_pwritev Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 20/34] qemu-img/convert: Use @opts for one thing only Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 21/34] qemu-img/convert: Move bs_n > 1 && -B check down Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 22/34] qemu-img: Document backing options Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 23/34] block/vhdx: Make vhdx_create() always set errp Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 24/34] block: Add errp to b{lk,drv}_truncate() Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 25/34] block: Add errp to BD.bdrv_truncate() Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 26/34] block: Add .bdrv_truncate() error messages Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 27/34] qcow2: Allow discard of final unaligned cluster Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 28/34] block: fix obvious coding style mistakes in block_int.h Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 29/34] block: assert no image modification under BDRV_O_INACTIVE Kevin Wolf
2017-04-28 20:33 ` Kevin Wolf [this message]
2017-04-28 20:33 ` [Qemu-devel] [PULL 31/34] qemu-img: use blk_co_pwrite_zeroes for zero sectors when compressed Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 32/34] iotests: clarify help text Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 33/34] iotests: fix exclusion option Kevin Wolf
2017-04-28 20:33 ` [Qemu-devel] [PULL 34/34] progress: Show current progress on SIGINFO Kevin Wolf
2017-05-04 12:46 ` [Qemu-devel] [Qemu-block] [PULL 00/34] Block layer patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493411622-5343-31-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).