From: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, vsementsov@yandex-team.ru,
jsnow@redhat.com, kwolf@redhat.com, hreitz@redhat.com,
qemu-devel@nongnu.org, andrey.drobyshev@virtuozzo.com,
den@virtuozzo.com
Subject: Re: [PATCH 3/4] block/copy-before-write: reverse access bitmap
Date: Wed, 21 May 2025 12:27:31 +0200 [thread overview]
Message-ID: <f309622e-dbab-4e2e-b153-36cf631ceeb0@virtuozzo.com> (raw)
In-Reply-To: <exbcf5hpdrc7lbcyhjgh4movj3fo2xt3sync62icuierlbtzeq@3z6venb5sxfc>
On 5/20/25 19:26, Eric Blake wrote:
> [?? ??????? ????????? ?????? ?? eblake@redhat.com. ???????, ?????? ??? ?????, ?? ?????? https://aka.ms/LearnAboutSenderIdentification ]
>
> On Tue, May 13, 2025 at 03:32:37AM +0200, Andrey Zhadchenko wrote:
>> HBitmaps allow us to search set bits pretty fast. On the contrary,
>> when searching zeroes, we may be forced to fully traverse the lower
>> level.
>> When we run blockdev-backup with mode=full on top of snapshot filter
>> + cbw filter, the job fills copy bitmap by calling block_status()
>> with range (X, virtual_size). The problem is that we check for zeroes
>> in this whole range. We also hit the worst case here, as access
>> bitmap is fully set and we need to scan the entire lowest level.
>> After scanning the full bitmap we actually ask the block status of
>> original image, which may return significantly lower amount of empty
>> clusters.
>> Beacuse of this, the backup job 'hangs' on block copy initializaiton
>> for a long time with 100% CPU.
>>
>> Example copy bitmap buildup time for image with clu_size=65536 and
>> preallocated metadata
>> size 10T 11T
>> blockdev-backup 52s 57s
>> cbw + snap 325s 413s
>> cbw + snap + patch 55s 61s
>>
>> To fix it, reverse the access bitmap in cbw filter: rather set it
>
> s/reverse/invert/
>
>> when the user is not allowed to read the cluster.
>>
>> Update qemu-iotest 257: now access bitmap have count 0 instead of
>> the image size 67108864
>>
>> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
>> ---
>> @@ -501,9 +501,12 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags,
>> return -EINVAL;
>> }
>> bdrv_disable_dirty_bitmap(s->access_bitmap);
>> - bdrv_dirty_bitmap_merge_internal(s->access_bitmap,
>> - block_copy_dirty_bitmap(s->bcs), NULL,
>> - true);
>> + if (bitmap) {
>> + bdrv_dirty_bitmap_merge_internal(s->access_bitmap,
>> + block_copy_dirty_bitmap(s->bcs), NULL,
>> + true);
>> + bdrv_dirty_bitmap_reverse(s->access_bitmap);
>
> Is this setting the bits correctly? Inverting a bitmap is a
> reversible operation, but it looks odd that you are only reversing
> once around the merge. Either the two sources of the merge have the
> same sense (whether that be 0 for dirty 1 for clean, or 0 for readable
> 1 for avoid) and no inverting is needed before or after the merge, or
> the two sources have opposite sense (in which case, I would have
> expected inverting one of the bitmaps before the merge to get them to
> agree on sense, then merging, then inverting back to the desired
> sense). Am I missing something?
We have just created access bitmap a few lines above. So it is empty:
everything is accessible.
- If cbw did not have any bitmap, we don't need to to do anything
- If someone set bitmap on cbw, we used it to init block-copy dirty
bitmap. So to get the access bitmap, we inverse the bitmap that marks
to-be-copied blocks: access bitmap now has all of them as 0 (allowed)
and not-to-be-copied as 1 (disallowed)
This case is also covered with iotests/image-fleecing with filter
snapshot + cbw bitmap case: some not-in-a-bitmap blocks are accessed and
we expect to get errors:
--- Sanity Check ---
read -P0x5d 0 64k
read -P0xd5 1M 64k
read -P0xdc 32M 64k
read -P0xcd 0x3ff0000 64k
read -P0 0x00f8000 32k
read failed: Invalid argument
read -P0 0x2010000 32k
read failed: Invalid argument
read -P0 0x3fe0000 64k
read failed: Invalid argument
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.
> Virtualization: qemu.org | libguestfs.org
>
next prev parent reply other threads:[~2025-05-21 10:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 1:32 [PATCH 0/4] improve block_status() for cbw + snapshot setup Andrey Zhadchenko
2025-05-13 1:32 ` [PATCH 1/4] hbitmap: drop meta bitmap leftovers Andrey Zhadchenko
2025-05-20 16:27 ` Eric Blake
2025-05-13 1:32 ` [PATCH 2/4] hbitmap: introduce hbitmap_reverse() Andrey Zhadchenko
2025-05-20 16:29 ` Eric Blake
2025-05-21 10:26 ` Andrey Zhadchenko
2025-05-13 1:32 ` [PATCH 3/4] block/copy-before-write: reverse access bitmap Andrey Zhadchenko
2025-05-20 17:26 ` Eric Blake
2025-05-21 10:27 ` Andrey Zhadchenko [this message]
2025-05-13 1:32 ` [PATCH 4/4] block/copy-before-write: report partial block status to snapshot Andrey Zhadchenko
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=f309622e-dbab-4e2e-b153-36cf631ceeb0@virtuozzo.com \
--to=andrey.zhadchenko@virtuozzo.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
/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).