[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH v4 05/17] dirty-bitmap: Change bdrv
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH v4 05/17] dirty-bitmap: Change bdrv_dirty_bitmap_size() to report bytes |
Date: |
Mon, 10 Jul 2017 16:19:47 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 07/10/2017 04:09 PM, John Snow wrote:
>
>
> On 07/03/2017 11:10 AM, Eric Blake wrote:
>> We are still using an internal hbitmap that tracks a size in sectors,
>> with the granularity scaled down accordingly, because it lets us
>> use a shortcut for our iterators which are currently sector-based.
>> But there's no reason we can't track the dirty bitmap size in bytes,
>> since it is (mostly) an internal-only variable (remember, the size
>> is how many bytes are covered by the bitmap, not how many bytes the
>> bitmap occupies). Furthermore, we're already reporting bytes for
>> bdrv_dirty_bitmap_granularity(); mixing bytes and sectors in our
>> return values is a recipe for confusion.
>>
>> The only external caller in qcow2-bitmap.c is temporarily more verbose
>> (because it is still using sector-based math), but will later be
>> switched to track progress by bytes instead of sectors.
>>
>> Use is_power_of_2() while at it, instead of open-coding that.
>>
>> Signed-off-by: Eric Blake <address@hidden>
>>
>> @@ -305,8 +307,10 @@ BdrvDirtyBitmap
>> *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,
>> void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
>> {
>> BdrvDirtyBitmap *bitmap;
>> - uint64_t size = bdrv_nb_sectors(bs);
>> + int64_t size = bdrv_getlength(bs);
>>
>> + assert(size >= 0);
>> + size = DIV_ROUND_UP(size, BDRV_SECTOR_SIZE);
>
> Do we need a TODO here as well, or are we going to track these in terms
> of "sectors" permanently?
The rounding goes away in patch 17/17 when I flip the internals to
byte-based. If a TODO comment here (that goes away in patch 17) makes
review easier, I can add that.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
[Qemu-block] [PATCH v4 07/17] qcow2: Switch sectors_covered_by_bitmap_cluster() to byte-based, Eric Blake, 2017/07/03
[Qemu-block] [PATCH v4 08/17] dirty-bitmap: Set iterator start by offset, not sector, Eric Blake, 2017/07/03
[Qemu-block] [PATCH v4 09/17] dirty-bitmap: Change bdrv_dirty_iter_next() to report byte offset, Eric Blake, 2017/07/03
[Qemu-block] [PATCH v4 11/17] dirty-bitmap: Change bdrv_get_dirty_locked() to take bytes, Eric Blake, 2017/07/03
[Qemu-block] [PATCH v4 10/17] dirty-bitmap: Change bdrv_get_dirty_count() to report bytes, Eric Blake, 2017/07/03