qcow2-bitmap: make bytes_covered_by_bitmap_cluster() public
Rename bytes_covered_by_bitmap_cluster() to bdrv_dirty_bitmap_serialization_coverage() and make it public. It is needed as we are going to share it with bitmap loading in parallels format. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Message-Id: <20210224104707.88430-2-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
05ae4e674e
commit
35f428ba39
@ -726,6 +726,19 @@ uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap)
|
|||||||
return hbitmap_serialization_align(bitmap->bitmap);
|
return hbitmap_serialization_align(bitmap->bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the disk size covered by a chunk of serialized bitmap data. */
|
||||||
|
uint64_t bdrv_dirty_bitmap_serialization_coverage(int serialized_chunk_size,
|
||||||
|
const BdrvDirtyBitmap *bitmap)
|
||||||
|
{
|
||||||
|
uint64_t granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
||||||
|
uint64_t limit = granularity * (serialized_chunk_size << 3);
|
||||||
|
|
||||||
|
assert(QEMU_IS_ALIGNED(limit,
|
||||||
|
bdrv_dirty_bitmap_serialization_align(bitmap)));
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
|
void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
|
||||||
uint8_t *buf, uint64_t offset,
|
uint8_t *buf, uint64_t offset,
|
||||||
uint64_t bytes)
|
uint64_t bytes)
|
||||||
|
@ -278,18 +278,6 @@ static int free_bitmap_clusters(BlockDriverState *bs, Qcow2BitmapTable *tb)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the disk size covered by a single qcow2 cluster of bitmap data. */
|
|
||||||
static uint64_t bytes_covered_by_bitmap_cluster(const BDRVQcow2State *s,
|
|
||||||
const BdrvDirtyBitmap *bitmap)
|
|
||||||
{
|
|
||||||
uint64_t granularity = bdrv_dirty_bitmap_granularity(bitmap);
|
|
||||||
uint64_t limit = granularity * (s->cluster_size << 3);
|
|
||||||
|
|
||||||
assert(QEMU_IS_ALIGNED(limit,
|
|
||||||
bdrv_dirty_bitmap_serialization_align(bitmap)));
|
|
||||||
return limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* load_bitmap_data
|
/* load_bitmap_data
|
||||||
* @bitmap_table entries must satisfy specification constraints.
|
* @bitmap_table entries must satisfy specification constraints.
|
||||||
* @bitmap must be cleared */
|
* @bitmap must be cleared */
|
||||||
@ -312,7 +300,7 @@ static int load_bitmap_data(BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = g_malloc(s->cluster_size);
|
buf = g_malloc(s->cluster_size);
|
||||||
limit = bytes_covered_by_bitmap_cluster(s, bitmap);
|
limit = bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bitmap);
|
||||||
for (i = 0, offset = 0; i < tab_size; ++i, offset += limit) {
|
for (i = 0, offset = 0; i < tab_size; ++i, offset += limit) {
|
||||||
uint64_t count = MIN(bm_size - offset, limit);
|
uint64_t count = MIN(bm_size - offset, limit);
|
||||||
uint64_t entry = bitmap_table[i];
|
uint64_t entry = bitmap_table[i];
|
||||||
@ -1303,7 +1291,7 @@ static uint64_t *store_bitmap_data(BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = g_malloc(s->cluster_size);
|
buf = g_malloc(s->cluster_size);
|
||||||
limit = bytes_covered_by_bitmap_cluster(s, bitmap);
|
limit = bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bitmap);
|
||||||
assert(DIV_ROUND_UP(bm_size, limit) == tb_size);
|
assert(DIV_ROUND_UP(bm_size, limit) == tb_size);
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
@ -57,6 +57,8 @@ void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter);
|
|||||||
uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap,
|
uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap,
|
||||||
uint64_t offset, uint64_t bytes);
|
uint64_t offset, uint64_t bytes);
|
||||||
uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap);
|
uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap);
|
||||||
|
uint64_t bdrv_dirty_bitmap_serialization_coverage(int serialized_chunk_size,
|
||||||
|
const BdrvDirtyBitmap *bitmap);
|
||||||
void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
|
void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
|
||||||
uint8_t *buf, uint64_t offset,
|
uint8_t *buf, uint64_t offset,
|
||||||
uint64_t bytes);
|
uint64_t bytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user