[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 05/12] hbitmap: enable merging across granularit
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH 05/12] hbitmap: enable merging across granularities |
Date: |
Thu, 20 Jun 2019 17:47:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 20.06.19 03:03, John Snow wrote:
> Signed-off-by: John Snow <address@hidden>
> ---
> util/hbitmap.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/util/hbitmap.c b/util/hbitmap.c
> index 45d1725daf..0d6724b7bc 100644
> --- a/util/hbitmap.c
> +++ b/util/hbitmap.c
> @@ -777,7 +777,17 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size)
>
> bool hbitmap_can_merge(const HBitmap *a, const HBitmap *b)
> {
> - return (a->size == b->size) && (a->granularity == b->granularity);
> + return (a->size == b->size);
> +}
> +
> +static void hbitmap_sparse_merge(HBitmap *dst, const HBitmap *src)
> +{
> + uint64_t offset = 0;
> + uint64_t count = src->orig_size;
> +
> + while (hbitmap_next_dirty_area(src, &offset, &count)) {
> + hbitmap_set(dst, offset, count);
> + }
> }
>
> /**
> @@ -804,6 +814,16 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b,
> HBitmap *result)
> return true;
> }
>
> + if (a->size != b->size) {
Don’t you mean s/size/granularity/?
Right now, this is dead code, which leads me to asking for a test.
(Well, no, I would’ve asked anyway.)
Max
> + if (a != result) {
> + hbitmap_sparse_merge(result, a);
> + }
> + if (b != result) {
> + hbitmap_sparse_merge(result, b);
> + }
> + return true;
> + }
> +
> /* This merge is O(size), as BITS_PER_LONG and HBITMAP_LEVELS are
> constant.
> * It may be possible to improve running times for sparsely populated
> maps
> * by using hbitmap_iter_next, but this is suboptimal for dense maps.
>
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH 07/12] block/backup: add 'always' bitmap sync policy, (continued)
[Qemu-devel] [PATCH 06/12] block/dirty-bitmap: add bdrv_dirty_bitmap_claim, John Snow, 2019/06/19
[Qemu-devel] [PATCH 04/12] hbitmap: Fix merge when b is empty, and result is not an alias of a, John Snow, 2019/06/19
[Qemu-devel] [PATCH 05/12] hbitmap: enable merging across granularities, John Snow, 2019/06/19
[Qemu-devel] [PATCH 11/12] iotests: add test 257 for bitmap-mode backups, John Snow, 2019/06/19
[Qemu-devel] [PATCH 03/12] block/backup: add 'never' policy to bitmap sync mode, John Snow, 2019/06/19