Received: from eggs.gnu.org ([208.118.235.92]:48123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF2Jo-0004cH-7T for qemu-devel@nongnu.org; Mon, 11 Mar 2013 08:59:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF2Jl-0004SJ-V4 for qemu-devel@nongnu.org; Mon, 11 Mar 2013 08:59:08 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:57198 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF2Jl-0004Rj-M9 for qemu-devel@nongnu.org; Mon, 11 Mar 2013 08:59:05 -0400 Date: Mon, 11 Mar 2013 13:59:56 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130311125956.GB3824@irqsave.net> References: <1360153926-9492-1-git-send-email-benoit@irqsave.net> <1360153926-9492-14-git-send-email-benoit@irqsave.net> <20130207094814.GH1081@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20130207094814.GH1081@stefanha-thinkpad.redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC V6 13/33] qcow2: make the deduplication forget a cluster hash when a cluster is to dedupe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Le Thursday 07 Feb 2013 =E0 10:48:14 (+0100), Stefan Hajnoczi a =E9crit : > On Wed, Feb 06, 2013 at 01:31:46PM +0100, Beno=EEt Canet wrote: > > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > > index ef91216..5b1d20d 100644 > > --- a/block/qcow2-cluster.c > > +++ b/block/qcow2-cluster.c > > @@ -710,6 +710,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState = *bs, QCowL2Meta *m) > > =20 > > for (i =3D 0; i < m->nb_clusters; i++) { > > uint64_t flags =3D 0; > > + uint64_t offset =3D cluster_offset + (i << s->cluster_bits); > > /* if two concurrent writes happen to the same unallocated c= luster > > * each write allocates separate cluster and writes data concurrent= ly. > > * The first one to complete updates l2 table with pointer to its > > @@ -722,8 +723,14 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState= *bs, QCowL2Meta *m) > > flags =3D m->oflag_copied ? QCOW_OFLAG_COPIED : 0; > > flags |=3D m->to_deduplicate ? QCOW_OFLAG_TO_DEDUP : 0; > > =20 > > - l2_table[l2_index + i] =3D cpu_to_be64((cluster_offset + > > - (i << s->cluster_bits)) | flags); > > + l2_table[l2_index + i] =3D cpu_to_be64(offset | flags); > > + > > + /* make the deduplication forget the cluster to avoid making > > + * the dedup pointing to a cluster that has changed on it's = back. > > + */ > > + if (m->to_deduplicate) { > > + qcow2_dedup_forget_cluster_by_sector(bs, offset >> 9); > > + } >=20 > This does not play well with internal snapshots. Imagine that an > internal snapshot was taken, so refcount =3D=3D 2. >=20 > Now the cluster is overwritten by the guest but we still need to hang o= n > to the original data since the snapshot refers to it. >=20 > If dedup forgets about the cluster then dedup is only effective for the > current disk image, but it ignores snapshots. Ideally dedup would take > snapshots into account since they share the same data clusters as the > current image. >=20 > Stefan Is checking the refcount with a qcow2_get_refcounts(index) a solution ?=20 Beno=EEt