qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qcow2: Simplify calculation for COW area at the


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH] qcow2: Simplify calculation for COW area at the end
Date: Tue, 12 Jun 2012 16:21:32 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

Am 12.06.2012 16:00, schrieb Paolo Bonzini:
> Il 12/06/2012 15:47, Kevin Wolf ha scritto:
>> copy_sectors() always uses the sum (cluster_offset + n_start) or
>> (start_sect + n_start), so if some value is added to both cluster_offset
>> and start_sect, and subtracted from n_start, it's cancelled out anyway.
>>
>> Signed-off-by: Kevin Wolf <address@hidden>
>> ---
>>  block/qcow2-cluster.c |    5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
>> index 9aee9fc..763b724 100644
>> --- a/block/qcow2-cluster.c
>> +++ b/block/qcow2-cluster.c
>> @@ -640,11 +640,10 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, 
>> QCowL2Meta *m)
>>      }
>>  
>>      if (m->nb_available & (s->cluster_sectors - 1)) {
>> -        uint64_t end = m->nb_available & ~(uint64_t)(s->cluster_sectors - 
>> 1);
>>          cow = true;
>>          qemu_co_mutex_unlock(&s->lock);
>> -        ret = copy_sectors(bs, start_sect + end, cluster_offset + (end << 
>> 9),
>> -                m->nb_available - end, s->cluster_sectors);
>> +        ret = copy_sectors(bs, start_sect, cluster_offset,
>> +                m->nb_available, s->cluster_sectors);
> 
> Do you need to add end to s->cluster_sectors too, so that "start_sect +
> n_end" and "n_end - n_start" remain the same?

You mean because n_end is now relative to start_sect instead of
start_sect + end, right?

I thought about it and I find this code is a bit confusing, but I think
you're right that I need to replace n_end as well because it would be
wrong for an allocating request than spans multiple clusters. I think
this one should be right, would you agree?

ret = copy_sectors(bs, start_sect, cluster_offset,
   m->nb_available, align_offset(m->nb_available, s->cluster_sectors));

The interesting question is why qemu-iotests doesn't catch it.

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]