From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org
Cc: kwolf@redhat.com, fam@euphon.net, qemu-devel@nongnu.org,
mreitz@redhat.com, den@openvz.org, jsnow@redhat.com
Subject: Re: [PATCH 01/10] hbitmap: introduce HBITMAP_MAX_ORIG_SIZE
Date: Wed, 9 Oct 2019 10:34:41 -0500 [thread overview]
Message-ID: <a128842b-d3c8-adb7-ec27-c07f59fd53fc@redhat.com> (raw)
In-Reply-To: <20190930151502.7829-2-vsementsov@virtuozzo.com>
On 9/30/19 10:14 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
A bit light on the commit message for explaining why.
> ---
> include/qemu/hbitmap.h | 7 +++++++
> util/hbitmap.c | 2 ++
> 2 files changed, 9 insertions(+)
>
> diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
> index 1bf944ca3d..82317c5364 100644
> --- a/include/qemu/hbitmap.h
> +++ b/include/qemu/hbitmap.h
> @@ -33,6 +33,13 @@ typedef struct HBitmapIter HBitmapIter;
> */
> #define HBITMAP_LEVELS ((HBITMAP_LOG_MAX_SIZE / BITS_PER_LEVEL) + 1)
>
> +/*
> + * We have APIs which returns signed int64_t, to be able to return error.
> + * Therefore we can't handle bitmaps with absolute size larger than
> + * (INT64_MAX+1). Still, keep it INT64_MAX to be a bit safer.
> + */
> +#define HBITMAP_MAX_ORIG_SIZE INT64_MAX
That, and bitmaps represent disk images, but disk images can't exceed
INT64_MAX bytes (thanks to off_t being signed). But does introducing a
new constant really help?
> +
> struct HBitmapIter {
> const HBitmap *hb;
>
> diff --git a/util/hbitmap.c b/util/hbitmap.c
> index 757d39e360..df192234e3 100644
> --- a/util/hbitmap.c
> +++ b/util/hbitmap.c
> @@ -708,6 +708,7 @@ HBitmap *hbitmap_alloc(uint64_t size, int granularity)
> HBitmap *hb = g_new0(struct HBitmap, 1);
> unsigned i;
>
> + assert(size <= HBITMAP_MAX_ORIG_SIZE);
or can we just inline INT64_MAX here?
> hb->orig_size = size;
>
> assert(granularity >= 0 && granularity < 64);
> @@ -738,6 +739,7 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size)
> uint64_t num_elements = size;
> uint64_t old;
>
> + assert(size <= HBITMAP_MAX_ORIG_SIZE);
> hb->orig_size = size;
>
> /* Size comes in as logical elements, adjust for granularity. */
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2019-10-09 19:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 15:14 [PATCH 00/10] Further bitmaps improvements Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 01/10] hbitmap: introduce HBITMAP_MAX_ORIG_SIZE Vladimir Sementsov-Ogievskiy
2019-10-09 15:34 ` Eric Blake [this message]
2019-10-09 16:04 ` Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 02/10] hbitmap: move hbitmap_iter_next_word to hbitmap.c Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 03/10] hbitmap: unpublish hbitmap_iter_skip_words Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 04/10] hbitmap: drop meta bitmaps as they are unused Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 05/10] block/dirty-bitmap: switch _next_dirty_area and _next_zero to int64_t Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 06/10] block/dirty-bitmap: add _next_dirty API Vladimir Sementsov-Ogievskiy
2019-09-30 15:14 ` [PATCH 07/10] block/dirty-bitmap: improve _next_dirty_area API Vladimir Sementsov-Ogievskiy
2019-09-30 15:15 ` [PATCH 08/10] nbd/server: introduce NBDExtentArray Vladimir Sementsov-Ogievskiy
2019-10-09 17:02 ` Eric Blake
2019-10-18 16:07 ` Vladimir Sementsov-Ogievskiy
2019-10-18 16:34 ` Eric Blake
2019-09-30 15:15 ` [PATCH 09/10] nbd/server: use bdrv_dirty_bitmap_next_dirty_area Vladimir Sementsov-Ogievskiy
2019-10-09 18:26 ` Eric Blake
2019-09-30 15:15 ` [PATCH 10/10] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty Vladimir Sementsov-Ogievskiy
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=a128842b-d3c8-adb7-ec27-c07f59fd53fc@redhat.com \
--to=eblake@redhat.com \
--cc=den@openvz.org \
--cc=fam@euphon.net \
--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).