From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WH01o-000099-PF for qemu-devel@nongnu.org; Fri, 21 Feb 2014 19:01:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WH01j-0003Jl-S0 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 19:01:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WH01j-0003Jf-E8 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 19:01:07 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1M016vs007129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Feb 2014 19:01:06 -0500 Message-ID: <5307E8C1.4070504@redhat.com> Date: Fri, 21 Feb 2014 17:01:05 -0700 From: Eric Blake MIME-Version: 1.0 References: <1393020771-32712-1-git-send-email-kwolf@redhat.com> <1393020771-32712-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1393020771-32712-2-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PduQsWXbBQhQkikncJkF0btmDjBAD6ntJ" Subject: Re: [Qemu-devel] [PULL 01/54] qcow2: Set zero flag for discarded clusters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PduQsWXbBQhQkikncJkF0btmDjBAD6ntJ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/21/2014 03:11 PM, Kevin Wolf wrote: > Instead of making the backing file contents visible again after a disca= rd > request, set the zero flag if possible (i.e. on version >=3D 3). >=20 > Signed-off-by: Kevin Wolf > Reviewed-by: Eric Blake > --- > block/qcow2-cluster.c | 22 ++++++++++++++++++++-- > tests/qemu-iotests/046 | 18 ++++++++++++++---- > 2 files changed, 34 insertions(+), 6 deletions(-) >=20 > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > index c57f39d..36c1bed 100644 > --- a/block/qcow2-cluster.c > +++ b/block/qcow2-cluster.c > @@ -1367,13 +1367,31 @@ static int discard_single_l2(BlockDriverState *= bs, uint64_t offset, > uint64_t old_offset; > =20 > old_offset =3D be64_to_cpu(l2_table[l2_index + i]); > - if ((old_offset & L2E_OFFSET_MASK) =3D=3D 0) { > + > + /* > + * Make sure that a discarded area reads back as zeroes for v3= images > + * (we cannot do it for v2 without actually writing a zero-fil= led > + * buffer). We can skip the operation if the cluster is alread= y marked > + * as zero, or if it's unallocated and we don't have a backing= file. > + * Possible idea for a followup: Is it possible with v2 images to write a single sector/cluster with all 0s, and to make all other writes of all-0 data bump the reference count of the magic known-zero cluster, so that we are at least conserving disk space by heavily reusing the known cluster? Then again, we may be reaching the point where no one cares about v2 images as much. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PduQsWXbBQhQkikncJkF0btmDjBAD6ntJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTB+jBAAoJEKeha0olJ0NqE8wIAKbfr5U6z5DJp5qnAsCiKCtZ n/FtXnWl9aPplQ5AoEM/3fZFcCXXeBTIpmvd/moGO8KfrEE3oo7PXWYW/wQ8tnFl PaZv39XRw1sGixvU6nqCiSp/+c+WDaVcB3kLf3GsyqWp0H+zuQrvOS944D3wXios DTlc3uo3tOskUkMCvIJJXujTdUZPZneAltI9LhBkgtXFEZSPOvEi4/o8iQ4py6Kd 6od4wN0HExTzQJ8vm8QL8pqwz5DLcxKGsU3Pge9GzY1OKhtNSq7G/ceb2G93Lz7H F7x3Jvnd7IwB6iEoq4/qIt8rqFuYQcqlg0B3i0tR0+pDeHsF9T6hfbimP4wdaK0= =nhMe -----END PGP SIGNATURE----- --PduQsWXbBQhQkikncJkF0btmDjBAD6ntJ--