qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com,
	qemu-devel@nongnu.org, mreitz@redhat.com, jsnow@redhat.com
Subject: [PATCH v4 10/10] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty
Date: Wed,  5 Feb 2020 14:20:41 +0300	[thread overview]
Message-ID: <20200205112041.6003-11-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20200205112041.6003-1-vsementsov@virtuozzo.com>

store_bitmap_data() loop does bdrv_set_dirty_iter() on each iteration,
which means that we actually don't need iterator itself and we can use
simpler bitmap API.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2-bitmap.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index d41f5d049b..82646c53bd 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1289,7 +1289,6 @@ static uint64_t *store_bitmap_data(BlockDriverState *bs,
     uint64_t bm_size = bdrv_dirty_bitmap_size(bitmap);
     const char *bm_name = bdrv_dirty_bitmap_name(bitmap);
     uint8_t *buf = NULL;
-    BdrvDirtyBitmapIter *dbi;
     uint64_t *tb;
     uint64_t tb_size =
             size_to_clusters(s,
@@ -1308,12 +1307,14 @@ static uint64_t *store_bitmap_data(BlockDriverState *bs,
         return NULL;
     }
 
-    dbi = bdrv_dirty_iter_new(bitmap);
     buf = g_malloc(s->cluster_size);
     limit = bytes_covered_by_bitmap_cluster(s, bitmap);
     assert(DIV_ROUND_UP(bm_size, limit) == tb_size);
 
-    while ((offset = bdrv_dirty_iter_next(dbi)) >= 0) {
+    offset = 0;
+    while ((offset = bdrv_dirty_bitmap_next_dirty(bitmap, offset, INT64_MAX))
+           >= 0)
+    {
         uint64_t cluster = offset / limit;
         uint64_t end, write_size;
         int64_t off;
@@ -1356,23 +1357,17 @@ static uint64_t *store_bitmap_data(BlockDriverState *bs,
             goto fail;
         }
 
-        if (end >= bm_size) {
-            break;
-        }
-
-        bdrv_set_dirty_iter(dbi, end);
+        offset = end;
     }
 
     *bitmap_table_size = tb_size;
     g_free(buf);
-    bdrv_dirty_iter_free(dbi);
 
     return tb;
 
 fail:
     clear_bitmap_table(bs, tb, tb_size);
     g_free(buf);
-    bdrv_dirty_iter_free(dbi);
     g_free(tb);
 
     return NULL;
-- 
2.21.0



  parent reply	other threads:[~2020-02-05 11:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 11:20 [PATCH v4 00/10] Further bitmaps improvements Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 01/10] hbitmap: assert that we don't create bitmap larger than INT64_MAX Vladimir Sementsov-Ogievskiy
2020-02-05 15:14   ` Eric Blake
2020-02-05 11:20 ` [PATCH v4 02/10] hbitmap: move hbitmap_iter_next_word to hbitmap.c Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 03/10] hbitmap: unpublish hbitmap_iter_skip_words Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 04/10] hbitmap: drop meta bitmaps as they are unused Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 05/10] block/dirty-bitmap: switch _next_dirty_area and _next_zero to int64_t Vladimir Sementsov-Ogievskiy
2020-02-26 12:39   ` Max Reitz
2020-02-05 11:20 ` [PATCH v4 06/10] block/dirty-bitmap: add _next_dirty API Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 07/10] block/dirty-bitmap: improve _next_dirty_area API Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 08/10] nbd/server: introduce NBDExtentArray Vladimir Sementsov-Ogievskiy
2020-02-26 15:06   ` Eric Blake
2020-02-27 12:46     ` Vladimir Sementsov-Ogievskiy
2020-02-27 13:21       ` Eric Blake
2020-03-06  7:44         ` Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` [PATCH v4 09/10] nbd/server: use bdrv_dirty_bitmap_next_dirty_area Vladimir Sementsov-Ogievskiy
2020-02-05 11:20 ` Vladimir Sementsov-Ogievskiy [this message]
2020-02-26  9:27 ` [PATCH v4 00/10] Further bitmaps improvements Vladimir Sementsov-Ogievskiy
2020-02-26 13:13 ` Max Reitz
2020-03-06  7:45   ` Vladimir Sementsov-Ogievskiy
2020-03-10 17:17     ` Max Reitz
2020-03-11  6:17       ` Vladimir Sementsov-Ogievskiy
2020-03-11  9:55         ` Max Reitz
2020-03-11 13:58           ` Vladimir Sementsov-Ogievskiy
2020-03-11 17:03             ` John Snow
2020-03-12  5:59               ` Vladimir Sementsov-Ogievskiy
2020-03-12 16:33                 ` John Snow
2020-03-12 20:41                 ` John Snow
2020-03-13  6:43                   ` 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=20200205112041.6003-11-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.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).