From 28636b8211c30e9b7ab05806a8824eabf377f307 Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 29 Jul 2019 16:35:53 -0400 Subject: block/dirty-bitmap: add bdrv_dirty_bitmap_get Add a public interface for get. While we're at it, rename "bdrv_get_dirty_bitmap_locked" to "bdrv_dirty_bitmap_get_locked". (There are more functions to rename to the bdrv_dirty_bitmap_VERB form, but they will wait until the conclusion of this series.) Signed-off-by: John Snow Reviewed-by: Max Reitz Message-id: 20190709232550.10724-11-jsnow@redhat.com Signed-off-by: John Snow --- block/dirty-bitmap.c | 19 ++++++++++++------- block/mirror.c | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'block') diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 7881fea684..75a5daf116 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -509,14 +509,19 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) } /* Called within bdrv_dirty_bitmap_lock..unlock */ -bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, - int64_t offset) +bool bdrv_dirty_bitmap_get_locked(BdrvDirtyBitmap *bitmap, int64_t offset) { - if (bitmap) { - return hbitmap_get(bitmap->bitmap, offset); - } else { - return false; - } + return hbitmap_get(bitmap->bitmap, offset); +} + +bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap *bitmap, int64_t offset) +{ + bool ret; + bdrv_dirty_bitmap_lock(bitmap); + ret = bdrv_dirty_bitmap_get_locked(bitmap, offset); + bdrv_dirty_bitmap_unlock(bitmap); + + return ret; } /** diff --git a/block/mirror.c b/block/mirror.c index 70f24d9ef6..2b870683f1 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -476,7 +476,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) int64_t next_offset = offset + nb_chunks * s->granularity; int64_t next_chunk = next_offset / s->granularity; if (next_offset >= s->bdev_length || - !bdrv_get_dirty_locked(source, s->dirty_bitmap, next_offset)) { + !bdrv_dirty_bitmap_get_locked(s->dirty_bitmap, next_offset)) { break; } if (test_bit(next_chunk, s->in_flight_bitmap)) { -- cgit v1.2.3