[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 16/18] qcow2: Switch store_bitmap_data() to b
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v6 16/18] qcow2: Switch store_bitmap_data() to byte-based iteration |
Date: |
Fri, 8 Sep 2017 09:09:24 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 09/08/2017 08:27 AM, Kevin Wolf wrote:
> Am 30.08.2017 um 23:05 hat Eric Blake geschrieben:
>> Now that we have adjusted the majority of the calls this function
>> makes to be byte-based, it is easier to read the code if it makes
>> passes over the image using bytes rather than sectors.
>>
>> Signed-off-by: Eric Blake <address@hidden>
>> Reviewed-by: John Snow <address@hidden>
>> Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
>>
>>
>> - while ((sector = bdrv_dirty_iter_next(dbi) >> BDRV_SECTOR_BITS) != -1) {
>> - uint64_t cluster = sector / sbc;
>> + while ((offset = bdrv_dirty_iter_next(dbi)) != -1) {
>
> Don't you have to multiply both sides of the equation? This would be
> offset != -512, which points out that the previous patch to convert
> bdrv_dirty_iter_next() to byte-based gave it a really awkward interface.
I think what I really need to do is change '!= -1' to '< 0', as that's
much easier to reason about when scaling is present.
>
>> + uint64_t cluster = offset / limit;
>> uint64_t end, write_size;
>> int64_t off;
>>
>> - sector = cluster * sbc;
>> - end = MIN(bm_sectors, sector + sbc);
>> - write_size = bdrv_dirty_bitmap_serialization_size(bitmap,
>> - sector * BDRV_SECTOR_SIZE, (end - sector) * BDRV_SECTOR_SIZE);
>> + offset = cluster * limit;
>
> You just had cluster = offset / limit, so in other words, align down
> offset? If so, this is how it should be written.
Thanks for the close reviews; looks like I have enough things to do a
respin.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature