qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 12/12] dirty-bitmap: Convert internal hbitmap size/granularity
Date: Wed, 12 Apr 2017 21:38:59 -0400	[thread overview]
Message-ID: <9543861a-bf8d-00d8-3048-4abf5186af44@redhat.com> (raw)
In-Reply-To: <20170412174920.8744-13-eblake@redhat.com>



On 04/12/2017 01:49 PM, Eric Blake wrote:
> Now that all callers are using byte-based interfaces, there's no
> reason for our internal hbitmap to remain with sector-based
> granularity.  It also simplifies our internal scaling, since we
> already know that hbitmap widens requests out to granularity
> boundaries.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  block/dirty-bitmap.c | 37 ++++++++++++-------------------------
>  1 file changed, 12 insertions(+), 25 deletions(-)
> 
> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> index ef165eb..26ca084 100644
> --- a/block/dirty-bitmap.c
> +++ b/block/dirty-bitmap.c
> @@ -37,7 +37,7 @@
>   *     or enabled. A frozen bitmap can only abdicate() or reclaim().
>   */
>  struct BdrvDirtyBitmap {
> -    HBitmap *bitmap;            /* Dirty sector bitmap implementation */
> +    HBitmap *bitmap;            /* Dirty bitmap implementation */
>      HBitmap *meta;              /* Meta dirty bitmap */
>      BdrvDirtyBitmap *successor; /* Anonymous child; implies frozen status */
>      char *name;                 /* Optional non-empty unique ID */
> @@ -93,12 +93,7 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
>          return NULL;
>      }
>      bitmap = g_new0(BdrvDirtyBitmap, 1);
> -    /*
> -     * TODO - let hbitmap track full granularity. For now, it is tracking
> -     * only sector granularity, as a shortcut for our iterators.
> -     */
> -    bitmap->bitmap = hbitmap_alloc(bitmap_size >> BDRV_SECTOR_BITS,
> -                                   ctz32(granularity) - BDRV_SECTOR_BITS);
> +    bitmap->bitmap = hbitmap_alloc(bitmap_size, ctz32(granularity));
>      bitmap->size = bitmap_size;
>      bitmap->name = g_strdup(name);
>      bitmap->disabled = false;
> @@ -254,7 +249,7 @@ void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
>      QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
>          assert(!bdrv_dirty_bitmap_frozen(bitmap));
>          assert(!bitmap->active_iterators);
> -        hbitmap_truncate(bitmap->bitmap, size >> BDRV_SECTOR_BITS);
> +        hbitmap_truncate(bitmap->bitmap, size);
>          bitmap->size = size;
>      }
>  }
> @@ -336,7 +331,7 @@ bool bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
>                      int64_t offset)
>  {
>      if (bitmap) {
> -        return hbitmap_get(bitmap->bitmap, offset >> BDRV_SECTOR_BITS);
> +        return hbitmap_get(bitmap->bitmap, offset);
>      } else {
>          return false;
>      }
> @@ -364,7 +359,7 @@ uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs)
> 
>  uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap)
>  {
> -    return BDRV_SECTOR_SIZE << hbitmap_granularity(bitmap->bitmap);
> +    return 1U << hbitmap_granularity(bitmap->bitmap);
>  }
> 
>  BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap)
> @@ -397,27 +392,21 @@ void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter)
> 
>  int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter)
>  {
> -    return hbitmap_iter_next(&iter->hbi) * BDRV_SECTOR_SIZE;
> +    return hbitmap_iter_next(&iter->hbi);
>  }
> 
>  void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
>                             int64_t offset, int64_t bytes)
>  {
> -    int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
> -
>      assert(bdrv_dirty_bitmap_enabled(bitmap));
> -    hbitmap_set(bitmap->bitmap, offset >> BDRV_SECTOR_BITS,
> -                end_sector - (offset >> BDRV_SECTOR_BITS));
> +    hbitmap_set(bitmap->bitmap, offset, bytes);
>  }
> 
>  void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
>                               int64_t offset, int64_t bytes)
>  {
> -    int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
> -
>      assert(bdrv_dirty_bitmap_enabled(bitmap));
> -    hbitmap_reset(bitmap->bitmap, offset >> BDRV_SECTOR_BITS,
> -                  end_sector - (offset >> BDRV_SECTOR_BITS));
> +    hbitmap_reset(bitmap->bitmap, offset, bytes);
>  }
> 
>  void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out)
> @@ -427,7 +416,7 @@ void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out)
>          hbitmap_reset_all(bitmap->bitmap);
>      } else {
>          HBitmap *backup = bitmap->bitmap;
> -        bitmap->bitmap = hbitmap_alloc(bitmap->size >> BDRV_SECTOR_BITS,
> +        bitmap->bitmap = hbitmap_alloc(bitmap->size,
>                                         hbitmap_granularity(backup));
>          *out = backup;
>      }
> @@ -481,14 +470,12 @@ void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap)
>  void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes)
>  {
>      BdrvDirtyBitmap *bitmap;
> -    int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE);
> 
>      QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
>          if (!bdrv_dirty_bitmap_enabled(bitmap)) {
>              continue;
>          }
> -        hbitmap_set(bitmap->bitmap, offset >> BDRV_SECTOR_BITS,
> -                    end_sector - (offset >> BDRV_SECTOR_BITS));
> +        hbitmap_set(bitmap->bitmap, offset, bytes);
>      }
>  }
> 
> @@ -497,12 +484,12 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes)
>   */
>  void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *iter, int64_t offset)
>  {
> -    hbitmap_iter_init(&iter->hbi, iter->hbi.hb, offset >> BDRV_SECTOR_BITS);
> +    hbitmap_iter_init(&iter->hbi, iter->hbi.hb, offset);
>  }
> 
>  int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap)
>  {
> -    return hbitmap_count(bitmap->bitmap) << BDRV_SECTOR_BITS;
> +    return hbitmap_count(bitmap->bitmap);
>  }
> 
>  int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap)
> 

Reviewed-by: John Snow <jsnow@redhat.com>

      reply	other threads:[~2017-04-13  1:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 17:49 [Qemu-devel] [PATCH 00/12] make dirty-bitmap byte-based Eric Blake
2017-04-12 17:49 ` [Qemu-devel] [PATCH 01/12] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented Eric Blake
2017-04-12 22:43   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 02/12] migration: Don't lose errno across aio context changes Eric Blake
2017-04-12 22:44   ` John Snow
2017-04-18 20:02   ` Juan Quintela
2017-04-12 17:49 ` [Qemu-devel] [PATCH 03/12] dirty-bitmap: Drop unused functions Eric Blake
2017-04-12 22:47   ` John Snow
2017-04-12 23:36     ` Eric Blake
2017-04-12 23:40       ` John Snow
2017-04-13  9:19         ` Vladimir Sementsov-Ogievskiy
2017-04-13 16:57           ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 04/12] dirty-bitmap: Track size in bytes Eric Blake
2017-04-12 23:32   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 05/12] dirty-bitmap: Set iterator start by offset, not sector Eric Blake
2017-04-13  0:00   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 06/12] dirty-bitmap: Change bdrv_dirty_iter_next() to report byte offset Eric Blake
2017-04-13  0:10   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 07/12] dirty-bitmap: Change bdrv_get_dirty_count() to report bytes Eric Blake
2017-04-13  0:19   ` John Snow
2017-04-13  0:22   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 08/12] dirty-bitmap: Change bdrv_get_dirty() to take bytes Eric Blake
2017-04-13  0:25   ` John Snow
2017-04-13  0:48     ` Eric Blake
2017-04-12 17:49 ` [Qemu-devel] [PATCH 09/12] dirty-bitmap: Change bdrv_[re]set_dirty_bitmap() to use bytes Eric Blake
2017-04-13  0:29   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 10/12] mirror: Switch mirror_dirty_init() to byte-based iteration Eric Blake
2017-04-13  1:24   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 11/12] dirty-bitmap: Switch bdrv_set_dirty() to bytes Eric Blake
2017-04-13  1:28   ` John Snow
2017-04-12 17:49 ` [Qemu-devel] [PATCH 12/12] dirty-bitmap: Convert internal hbitmap size/granularity Eric Blake
2017-04-13  1:38   ` John Snow [this message]

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=9543861a-bf8d-00d8-3048-4abf5186af44@redhat.com \
    --to=jsnow@redhat.com \
    --cc=eblake@redhat.com \
    --cc=famz@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).