From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur7pk-0007Kp-Va for qemu-devel@nongnu.org; Mon, 24 Jun 2013 10:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur7pj-0005ed-Hb for qemu-devel@nongnu.org; Mon, 24 Jun 2013 10:33:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur7pj-0005eX-9T for qemu-devel@nongnu.org; Mon, 24 Jun 2013 10:33:31 -0400 Message-ID: <51C858B3.7010200@redhat.com> Date: Mon, 24 Jun 2013 16:33:23 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1371934712-11714-1-git-send-email-pl@kamp.de> <1371934712-11714-7-git-send-email-pl@kamp.de> In-Reply-To: <1371934712-11714-7-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 6/8] qemu-img: use bdrv_write_zeroes to write zeroes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Kevin Wolf , ronniesahlberg@gmail.com, qemu-devel@nongnu.org, Stefan Hajnoczi Il 22/06/2013 22:58, Peter Lieven ha scritto: > Signed-off-by: Peter Lieven > --- > 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); I think it should still do the write only if !has_zero_init. Paolo > + } > if (ret < 0) { > error_report("error while writing sector %" PRId64 > ": %s", sector_num, strerror(-ret)); >