[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 11/11] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty
From: |
John Snow |
Subject: |
[PULL v2 11/11] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty |
Date: |
Wed, 18 Mar 2020 16:23:41 -0400 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
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 <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: John Snow <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
---
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 8cccc2c9f3..cb06954b4a 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1288,7 +1288,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,
@@ -1307,12 +1306,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;
@@ -1355,23 +1356,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.1
- [PULL v2 00/11] Bitmaps patches, John Snow, 2020/03/18
- [PULL v2 01/11] build: Silence clang warning on older glib autoptr usage, John Snow, 2020/03/18
- [PULL v2 02/11] hbitmap: assert that we don't create bitmap larger than INT64_MAX, John Snow, 2020/03/18
- [PULL v2 03/11] hbitmap: move hbitmap_iter_next_word to hbitmap.c, John Snow, 2020/03/18
- [PULL v2 04/11] hbitmap: unpublish hbitmap_iter_skip_words, John Snow, 2020/03/18
- [PULL v2 09/11] nbd/server: introduce NBDExtentArray, John Snow, 2020/03/18
- [PULL v2 08/11] block/dirty-bitmap: improve _next_dirty_area API, John Snow, 2020/03/18
- [PULL v2 10/11] nbd/server: use bdrv_dirty_bitmap_next_dirty_area, John Snow, 2020/03/18
- [PULL v2 05/11] hbitmap: drop meta bitmaps as they are unused, John Snow, 2020/03/18
- [PULL v2 11/11] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty,
John Snow <=
- [PULL v2 07/11] block/dirty-bitmap: add _next_dirty API, John Snow, 2020/03/18
- [PULL v2 06/11] block/dirty-bitmap: switch _next_dirty_area and _next_zero to int64_t, John Snow, 2020/03/18
- Re: [PULL v2 00/11] Bitmaps patches, Peter Maydell, 2020/03/19