[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [5860] Cleanup {alloc|get}_cluster_offset() (Gleb Natap
From: |
Gleb Natapov |
Subject: |
Re: [Qemu-devel] [5860] Cleanup {alloc|get}_cluster_offset() (Gleb Natapov) |
Date: |
Thu, 11 Dec 2008 19:42:04 +0200 |
On Thu, Dec 11, 2008 at 06:32:58PM +0100, Kevin Wolf wrote:
> Am Do 11 Dez 2008 12:00:56 CET schrieb Gleb Natapov <address@hidden>:
>
>> 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?
>
> Hm, no signed-off line yet. Anyway:
>
Here it is ;)
Signed-off-by: Gleb Natapov <address@hidden>
> Acked-by: Kevin Wolf <address@hidden>
>
>>
>>
>> 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.