From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, jsnow@redhat.com,
vsementsov@virtuozzo.com, qemu-block@nongnu.org,
Fam Zheng <famz@redhat.com>, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 05/18] dirty-bitmap: Change bdrv_dirty_bitmap_size() to report bytes
Date: Fri, 8 Sep 2017 09:04:15 -0500 [thread overview]
Message-ID: <cdd49114-e1a6-a2d2-8d6b-97d83d9d4be6@redhat.com> (raw)
In-Reply-To: <20170908122254.GG3283@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2787 bytes --]
On 09/08/2017 07:22 AM, Kevin Wolf wrote:
> Am 30.08.2017 um 23:05 hat Eric Blake geschrieben:
>> 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. A later cleanup will
>> convert dirty bitmap internals to be entirely byte-based,
>> eliminating the intermediate sector rounding added here; and
>> technically, since bdrv_getlength() already rounds up to sectors,
>> our use of DIV_ROUND_UP is more for theoretical completeness than
>> for any actual rounding.
>>
>> 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, and
>> add an assertion where bdrv_getlength() should not fail.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: John Snow <jsnow@redhat.com>
>
> I think I would have preferred to change the unit of
> BdrvDirtyBitmap.size in one patch and the unit of the return value of
> bdrv_dirty_bitmap_size() in another one to keep review a bit easier.
I can split on respin, if there's still enough reason for a respin.
>> @@ -305,13 +307,14 @@ 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);
>
> How can you assert that there will never be an error? Even if it's
> correct (I don't know whether you can have dirty bitmaps on devices that
> don't use the cached value), this needs at least a comment.
The old code wasn't checking for errors; if an error occurs, we have no
way to report it. So I indeed need to audit whether all callers have a
cached length at this point in time (it can't fail), or else change
bdrv_dirty_bitmap_truncate() to be able to fail (pass failure along) and
update all callers. This may indeed be reason for a respin, depending
on what I find.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-09-08 14:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 21:05 [Qemu-devel] [PATCH v6 00/18] make dirty-bitmap byte-based Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 01/18] block: Make bdrv_img_create() size selection easier to read Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 02/18] hbitmap: Rename serialization_granularity to serialization_align Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 03/18] qcow2: Ensure bitmap serialization is aligned Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 04/18] dirty-bitmap: Drop unused functions Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 05/18] dirty-bitmap: Change bdrv_dirty_bitmap_size() to report bytes Eric Blake
2017-09-08 12:22 ` Kevin Wolf
2017-09-08 14:04 ` Eric Blake [this message]
2017-09-12 19:35 ` Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 06/18] dirty-bitmap: Change bdrv_dirty_bitmap_*serialize*() to take bytes Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 07/18] qcow2: Switch sectors_covered_by_bitmap_cluster() to byte-based Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 08/18] dirty-bitmap: Set iterator start by offset, not sector Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 09/18] dirty-bitmap: Change bdrv_dirty_iter_next() to report byte offset Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 10/18] dirty-bitmap: Change bdrv_get_dirty_count() to report bytes Eric Blake
2017-09-08 12:51 ` Kevin Wolf
2017-09-08 14:05 ` Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 11/18] dirty-bitmap: Change bdrv_get_dirty_locked() to take bytes Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 12/18] dirty-bitmap: Change bdrv_[re]set_dirty_bitmap() to use bytes Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 13/18] mirror: Switch mirror_dirty_init() to byte-based iteration Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 14/18] qcow2: Switch qcow2_measure() " Eric Blake
2017-09-08 13:15 ` Kevin Wolf
2017-09-08 13:43 ` Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 15/18] qcow2: Switch load_bitmap_data() " Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 16/18] qcow2: Switch store_bitmap_data() " Eric Blake
2017-09-08 13:27 ` Kevin Wolf
2017-09-08 14:09 ` Eric Blake
2017-09-08 14:16 ` Kevin Wolf
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 17/18] dirty-bitmap: Switch bdrv_set_dirty() to bytes Eric Blake
2017-08-30 21:05 ` [Qemu-devel] [PATCH v6 18/18] dirty-bitmap: Convert internal hbitmap size/granularity Eric Blake
2017-08-30 22:43 ` [Qemu-devel] [PATCH v6 00/18] make dirty-bitmap byte-based John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cdd49114-e1a6-a2d2-8d6b-97d83d9d4be6@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).