qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@kamp.de>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	pbonzini@redhat.com, Peter Lieven <pl@kamp.de>,
	ronniesahlberg@gmail.com, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 6/8] qemu-img: use bdrv_write_zeroes to write zeroes
Date: Sat, 22 Jun 2013 22:58:30 +0200	[thread overview]
Message-ID: <1371934712-11714-7-git-send-email-pl@kamp.de> (raw)
In-Reply-To: <1371934712-11714-1-git-send-email-pl@kamp.de>

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 qemu-img.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 809b4f1..5aa53ab 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1513,9 +1513,13 @@ static int img_convert(int argc, char **argv)
                    If the output is to a host device, we also write out
                    sectors that are entirely 0, since whatever data was
                    already there is garbage, not 0s. */
-                if (!has_zero_init || out_baseimg ||
-                    is_allocated_sectors_min(buf1, n, &n1, min_sparse)) {
-                    ret = bdrv_write(out_bs, sector_num, buf1, n1);
+                int allocated = is_allocated_sectors_min(buf1, n, &n1, min_sparse);
+                if (!has_zero_init || out_baseimg || allocated) {
+                    if (allocated || out_baseimg) {
+                        ret = bdrv_write(out_bs, sector_num, buf1, n1);
+                    } else {
+                        ret = bdrv_write_zeroes(out_bs, sector_num, n1);
+                    }
                     if (ret < 0) {
                         error_report("error while writing sector %" PRId64
                                      ": %s", sector_num, strerror(-ret));
-- 
1.7.9.5

  parent reply	other threads:[~2013-06-22 20:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-22 20:58 [Qemu-devel] [PATCH 0/8] iscsi/qemu-img/block-migration enhancements Peter Lieven
2013-06-22 20:58 ` [Qemu-devel] [PATCH 1/8] iscsi: add logical block provisioning information to iscsilun Peter Lieven
2013-06-24 14:35   ` Paolo Bonzini
2013-06-22 20:58 ` [Qemu-devel] [PATCH 2/8] iscsi: add bdrv_co_is_allocated Peter Lieven
2013-06-24 14:36   ` Paolo Bonzini
2013-06-22 20:58 ` [Qemu-devel] [PATCH 3/8] iscsi: add bdrv_co_write_zeroes Peter Lieven
2013-06-24 14:34   ` Paolo Bonzini
2013-06-24 16:31     ` Peter Lieven
2013-06-22 20:58 ` [Qemu-devel] [PATCH 4/8] block: add bdrv_write_zeroes() Peter Lieven
2013-06-22 20:58 ` [Qemu-devel] [PATCH 5/8] block/raw: add bdrv_co_write_zeroes Peter Lieven
2013-06-22 20:58 ` Peter Lieven [this message]
2013-06-24 14:33   ` [Qemu-devel] [PATCH 6/8] qemu-img: use bdrv_write_zeroes to write zeroes Paolo Bonzini
2013-06-24 16:17     ` Peter Lieven
2013-06-24 16:25       ` Paolo Bonzini
2013-06-24 16:33         ` Peter Lieven
2013-06-24 18:46         ` Peter Lieven
2013-06-22 20:58 ` [Qemu-devel] [PATCH 7/8] iscsi: assert that sectors are aligned to LUN blocksize Peter Lieven
2013-06-24 14:30   ` Paolo Bonzini
2013-06-24 16:10     ` Peter Lieven
2013-06-24 16:13       ` Paolo Bonzini
2013-06-24 16:24         ` Peter Lieven
2013-06-24 16:27           ` Paolo Bonzini
2013-06-24 16:36             ` Peter Lieven
2013-06-22 20:58 ` [Qemu-devel] [PATCH 8/8] block-migration: efficiently encode zero blocks Peter Lieven
2013-06-24 14:32   ` Paolo Bonzini
2013-06-24 16:14     ` Peter Lieven

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=1371934712-11714-7-git-send-email-pl@kamp.de \
    --to=pl@kamp.de \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=stefanha@redhat.com \
    /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).