Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LApPM-00085t-U4 for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:33:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LApPM-00085A-2o for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:33:04 -0500 Received: from [199.232.76.173] (port=39639 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LApPL-00084w-QA for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:33:03 -0500 Received: from ns.suse.de ([195.135.220.2]:55093 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LApPL-0004Ho-9q for qemu-devel@nongnu.org; Thu, 11 Dec 2008 12:33:03 -0500 Message-ID: <20081211183258.fqitybgdw8gwgocs@imap.suse.de> Date: Thu, 11 Dec 2008 18:32:58 +0100 From: Kevin Wolf Subject: Re: [Qemu-devel] [5860] Cleanup {alloc|get}_cluster_offset() (Gleb Natapov) References: <493FD45B.5010500@codemonkey.ws> <20081211110056.GJ5555@redhat.com> In-Reply-To: <20081211110056.GJ5555@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org, Alexander Graf Am Do 11 Dez 2008 12:00:56 CET schrieb Gleb Natapov : > On Wed, Dec 10, 2008 at 08:38:19AM -0600, Anthony Liguori wrote: >> Hi Gleb, >> >> Anthony Liguori wrote: >>> Revision: 5860 >>> http://svn.sv.gnu.org/viewvc/?view=3Drev&root=3Dqemu&revision= =3D5860 >>> Author: aliguori >>> Date: 2008-12-02 20:11:27 +0000 (Tue, 02 Dec 2008) >>> >> >> According to https://bugzilla.novell.com/show_bug.cgi?id=3D457957, this >> changeset breaks compressed qcow2 on write and savevm. >> >> Can you please look into this? >> > Alexander, can you try the patch below? Hm, no signed-off line yet. Anyway: Acked-by: Kevin Wolf > > > diff --git a/block-qcow2.c b/block-qcow2.c > index b3b5f8f..d8ac647 100644 > --- a/block-qcow2.c > +++ b/block-qcow2.c > @@ -620,6 +620,9 @@ static int count_contiguous_clusters(uint64_t =20 > nb_clusters, int cluster_size, > int i; > uint64_t offset =3D be64_to_cpu(l2_table[0]) & ~mask; > > + if (!offset) > + return 0; > + > for (i =3D 0; i < nb_clusters; i++) > if (offset + i * cluster_size !=3D (be64_to_cpu(l2_table[i]) & ~m= ask)) > break; > @@ -981,6 +984,12 @@ static uint64_t =20 > alloc_cluster_offset(BlockDriverState *bs, > /* how many available clusters ? */ > > while (i < nb_clusters) { > + i +=3D count_contiguous_clusters(nb_clusters - i, s->cluster_size= , > + &l2_table[l2_index + i], 0); > + > + if(be64_to_cpu(l2_table[l2_index + i])) > + break; > + > i +=3D count_contiguous_free_clusters(nb_clusters - i, > &l2_table[l2_index + i]); > > @@ -989,12 +998,6 @@ static uint64_t =20 > alloc_cluster_offset(BlockDriverState *bs, > if ((cluster_offset & QCOW_OFLAG_COPIED) || > (cluster_offset & QCOW_OFLAG_COMPRESSED)) > break; > - > - i +=3D count_contiguous_clusters(nb_clusters - i, s->cluster_size= , > - &l2_table[l2_index + i], 0); > - > - if(be64_to_cpu(l2_table[l2_index + i])) > - break; > } > nb_clusters =3D i; > > -- > =09=09=09Gleb. > > >