From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHs71-0001Rf-GM for qemu-devel@nongnu.org; Mon, 24 Feb 2014 04:46:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WHs6u-0005Ri-25 for qemu-devel@nongnu.org; Mon, 24 Feb 2014 04:46:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHs6t-0005RY-Pn for qemu-devel@nongnu.org; Mon, 24 Feb 2014 04:46:03 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1O9k0LE010405 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 24 Feb 2014 04:46:00 -0500 Date: Mon, 24 Feb 2014 10:46:02 +0100 From: Kevin Wolf Message-ID: <20140224094602.GD3775@dhcp-200-207.str.redhat.com> References: <1393020771-32712-1-git-send-email-kwolf@redhat.com> <1393020771-32712-2-git-send-email-kwolf@redhat.com> <5307E8C1.4070504@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline In-Reply-To: <5307E8C1.4070504@redhat.com> 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: Eric Blake Cc: qemu-devel@nongnu.org --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 22.02.2014 um 01:01 hat Eric Blake geschrieben: > 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. > > + * >=20 > Possible idea for a followup: >=20 > 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? No, that doesn't work because when you have multiple virtual clusters pointing to the same physical cluster in a single snapshot, you can't guarantee any more that QCOW_OFLAG_COPIED is set correctly. Ironically, I guess you could still do it in v3 when you set the dirty flag of lazy refcounting, but we don't have that in v2 either... > Then again, we may be reaching the point where no one cares about v2 > images as much. Right, that too. Kevin --sdtB3X0nJg68CQEu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJTCxTZAAoJEH8JsnLIjy/WZdIQAKJ6tcsGQs7z7y63ZEsAF8Sb FHZUPDf++x8F2ZRQpcd4TwTifSDGBuxoMFTWsfGhDI2QeKHtHAqsU8rwmH33eAmu cJj4zVcMsbRLUUr0Tq9Tj/W1oQGibwRHqjy2Gj1mjUiWu2JCNiMuzVfExPtitiST YuMBZ0aXNqW9b/hICMnO71KmF5pJ+d6nRS9uDE/nFaezcLgLTKvsQSR+QCK+qIOp yTPSG3QGE/wtcOv3n9pFRRZZZPCQ6HMrfKxWcgUvNNRB803MFjavtYPByilslWBp MhNeFetANhseqJSMatE37XeCX2vYgZy+vVnrew5cZTv+jalFUJsqmYweCqIEQsZL +pXyz/4LhlBJBd+8X9q0V5UuHPQpJOq3EAfpHIf2Mmt5wuNv1qbd0zyeINqkDVKK XPbs3Gx1NpCtIy6SFGJysLuJ91YXwPdt/NEx97s1MV22dn+sxuesqKpBGyNgGPus 5ceKaY2Fr9bwPepCo3RXKyTb0eWFb6H9RWlquGP2mDOn7qrLm9//N/sxSizvTT7B Z1fpaVVbI35auQq9N/lC14cmv71HuzInOMYKhMgxvP49aDxXSR7jGjl4qMuCwbCm /VT6LAxcbQQXZZ+WuhRtcJDCzv02zM3jEgnl+dvfXRvkNG0+UDXx/n6bP89a0lgK iOKhSL7Xyi9iLFRgZcfy =6CH9 -----END PGP SIGNATURE----- --sdtB3X0nJg68CQEu--