From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LAm31-00036U-Gr for qemu-devel@nongnu.org; Thu, 11 Dec 2008 08:57:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LAm2z-00035z-SY for qemu-devel@nongnu.org; Thu, 11 Dec 2008 08:57:46 -0500 Received: from [199.232.76.173] (port=52894 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LAm2z-00035b-LD for qemu-devel@nongnu.org; Thu, 11 Dec 2008 08:57:45 -0500 Received: from mx2.redhat.com ([66.187.237.31]:51309) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LAm2y-0003fD-UZ for qemu-devel@nongnu.org; Thu, 11 Dec 2008 08:57:45 -0500 Date: Thu, 11 Dec 2008 15:58:30 +0200 From: Gleb Natapov Subject: Re: [Qemu-devel] [5860] Cleanup {alloc|get}_cluster_offset() (Gleb Natapov) Message-ID: <20081211135830.GK5555@redhat.com> References: <493FD45B.5010500@codemonkey.ws> <20081211110056.GJ5555@redhat.com> <9CEE268A-19F4-472C-8A30-EF72E048D927@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9CEE268A-19F4-472C-8A30-EF72E048D927@suse.de> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: qemu-devel@nongnu.org On Thu, Dec 11, 2008 at 02:21:44PM +0100, Alexander Graf wrote: > Gleb, > > do you have a Novell bugzilla account, so I can add you to the bug? Just opened one: glebn. > Kevin apparently used some of his spare time (he's on vacation) to look > at this as well. > > Alex > > On 11.12.2008, at 12:00, Gleb Natapov wrote: > >> 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=rev&root=qemu&revision=5860 >>>> Author: aliguori >>>> Date: 2008-12-02 20:11:27 +0000 (Tue, 02 Dec 2008) >>>> >>> >>> According to https://bugzilla.novell.com/show_bug.cgi?id=457957, this >>> changeset breaks compressed qcow2 on write and savevm. >>> >>> Can you please look into this? >>> >> Alexander, can you try the patch below? >> >> >> 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 >> nb_clusters, int cluster_size, >> int i; >> uint64_t offset = be64_to_cpu(l2_table[0]) & ~mask; >> >> + if (!offset) >> + return 0; >> + >> for (i = 0; i < nb_clusters; i++) >> if (offset + i * cluster_size != (be64_to_cpu(l2_table[i]) & >> ~mask)) >> break; >> @@ -981,6 +984,12 @@ static uint64_t >> alloc_cluster_offset(BlockDriverState *bs, >> /* how many available clusters ? */ >> >> while (i < nb_clusters) { >> + i += 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 += count_contiguous_free_clusters(nb_clusters - i, >> &l2_table[l2_index + i]); >> >> @@ -989,12 +998,6 @@ static uint64_t >> alloc_cluster_offset(BlockDriverState *bs, >> if ((cluster_offset & QCOW_OFLAG_COPIED) || >> (cluster_offset & QCOW_OFLAG_COMPRESSED)) >> break; >> - >> - i += 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 = i; >> >> -- >> Gleb. -- Gleb.