From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 14/17] qcow2: Switch load_bitmap_data() to byte-based iteration
Date: Thu, 13 Jul 2017 12:16:53 +0300 [thread overview]
Message-ID: <6a1fb943-160b-2e47-b985-dc9af86c9634@virtuozzo.com> (raw)
In-Reply-To: <20170703151051.31327-15-eblake@redhat.com>
03.07.2017 18:10, Eric Blake wrote:
> 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 <eblake@redhat.com>
>
> ---
> v4: new patch
> ---
> block/qcow2-bitmap.c | 22 ++++++++--------------
> 1 file changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index 280960a..1de2ab5 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -291,9 +291,8 @@ static int load_bitmap_data(BlockDriverState *bs,
> {
> int ret = 0;
> BDRVQcow2State *s = bs->opaque;
> - uint64_t sector, limit, sbc;
> + uint64_t offset, limit;
> uint64_t bm_size = bdrv_dirty_bitmap_size(bitmap);
> - uint64_t bm_sectors = DIV_ROUND_UP(bm_size, BDRV_SECTOR_SIZE);
> uint8_t *buf = NULL;
> uint64_t i, tab_size =
> size_to_clusters(s,
> @@ -305,32 +304,27 @@ static int load_bitmap_data(BlockDriverState *bs,
>
> buf = g_malloc(s->cluster_size);
> limit = bytes_covered_by_bitmap_cluster(s, bitmap);
> - sbc = limit >> BDRV_SECTOR_BITS;
> - for (i = 0, sector = 0; i < tab_size; ++i, sector += sbc) {
> - uint64_t count = MIN(bm_sectors - sector, sbc);
> + for (i = 0, offset = 0; i < tab_size; ++i, offset += limit) {
> + uint64_t count = MIN(bm_size - offset, limit);
> uint64_t entry = bitmap_table[i];
> - uint64_t offset = entry & BME_TABLE_ENTRY_OFFSET_MASK;
> + uint64_t data_offset = entry & BME_TABLE_ENTRY_OFFSET_MASK;
>
> assert(check_table_entry(entry, s->cluster_size) == 0);
>
> - if (offset == 0) {
> + if (data_offset == 0) {
> if (entry & BME_TABLE_ENTRY_FLAG_ALL_ONES) {
> - bdrv_dirty_bitmap_deserialize_ones(bitmap,
> - sector * BDRV_SECTOR_SIZE,
> - count * BDRV_SECTOR_SIZE,
> + bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count,
The change is that now 3rd parameter may not be aligned by sectors, but
looks like it should be ok.
Reviewed-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
> false);
> } else {
> /* No need to deserialize zeros because the dirty bitmap is
> * already cleared */
> }
> } else {
> - ret = bdrv_pread(bs->file, offset, buf, s->cluster_size);
> + ret = bdrv_pread(bs->file, data_offset, buf, s->cluster_size);
> if (ret < 0) {
> goto finish;
> }
> - bdrv_dirty_bitmap_deserialize_part(bitmap, buf,
> - sector * BDRV_SECTOR_SIZE,
> - count * BDRV_SECTOR_SIZE,
> + bdrv_dirty_bitmap_deserialize_part(bitmap, buf, offset, count,
> false);
> }
> }
--
Best regards,
Vladimir
next prev parent reply other threads:[~2017-07-13 9:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-03 15:10 [Qemu-devel] [PATCH v4 00/17] make dirty-bitmap byte-based Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 01/17] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 02/17] hbitmap: Rename serialization_granularity to serialization_align Eric Blake
2017-07-06 23:03 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 03/17] qcow2: Ensure bitmap serialization is aligned Eric Blake
2017-07-06 23:14 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 04/17] dirty-bitmap: Drop unused functions Eric Blake
2017-07-06 23:43 ` John Snow
2017-07-07 8:44 ` Vladimir Sementsov-Ogievskiy
2017-07-07 13:05 ` Vladimir Sementsov-Ogievskiy
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 05/17] dirty-bitmap: Change bdrv_dirty_bitmap_size() to report bytes Eric Blake
2017-07-10 21:09 ` John Snow
2017-07-10 21:19 ` Eric Blake
2017-07-10 21:20 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 06/17] dirty-bitmap: Change bdrv_dirty_bitmap_*serialize*() to take bytes Eric Blake
2017-07-10 21:46 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 07/17] qcow2: Switch sectors_covered_by_bitmap_cluster() to byte-based Eric Blake
2017-07-10 22:54 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 08/17] dirty-bitmap: Set iterator start by offset, not sector Eric Blake
2017-07-10 23:02 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 09/17] dirty-bitmap: Change bdrv_dirty_iter_next() to report byte offset Eric Blake
2017-07-10 23:20 ` John Snow
2017-07-11 16:50 ` Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 10/17] dirty-bitmap: Change bdrv_get_dirty_count() to report bytes Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 11/17] dirty-bitmap: Change bdrv_get_dirty_locked() to take bytes Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 12/17] dirty-bitmap: Change bdrv_[re]set_dirty_bitmap() to use bytes Eric Blake
2017-07-12 19:25 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 13/17] mirror: Switch mirror_dirty_init() to byte-based iteration Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 14/17] qcow2: Switch load_bitmap_data() " Eric Blake
2017-07-12 20:15 ` John Snow
2017-07-13 9:16 ` Vladimir Sementsov-Ogievskiy [this message]
2017-07-13 10:59 ` Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 15/17] qcow2: Switch store_bitmap_data() " Eric Blake
2017-07-12 20:28 ` John Snow
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 16/17] dirty-bitmap: Switch bdrv_set_dirty() to bytes Eric Blake
2017-07-03 15:10 ` [Qemu-devel] [PATCH v4 17/17] dirty-bitmap: Convert internal hbitmap size/granularity Eric Blake
2017-07-12 21:00 ` John Snow
2017-07-12 21:25 ` Eric Blake
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=6a1fb943-160b-2e47-b985-dc9af86c9634@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).