[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 14/54] dirty-bitmap: Change bdrv_get_dirty_locked() t
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 14/54] dirty-bitmap: Change bdrv_get_dirty_locked() to take bytes |
Date: |
Fri, 6 Oct 2017 17:53:42 +0200 |
From: Eric Blake <address@hidden>
Half the callers were already scaling bytes to sectors; the other
half can eventually be simplified to use byte iteration. Both
callers were already using the result as a bool, so make that
explicit. Making the change also makes it easier for a future
dirty-bitmap patch to offload scaling over to the internal hbitmap.
Remember, asking whether a byte is dirty is effectively asking
whether the entire granularity containing the byte is dirty, since
we only track dirtiness by granularity.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: John Snow <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
include/block/dirty-bitmap.h | 4 ++--
block/dirty-bitmap.c | 8 ++++----
block/mirror.c | 3 +--
migration/block.c | 3 ++-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 757fc4c5b8..9e39537e4b 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -72,8 +72,8 @@ void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap
*bitmap,
/* Functions that require manual locking. */
void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap);
void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap);
-int bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
- int64_t sector);
+bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
+ int64_t offset);
void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
int64_t cur_sector, int64_t nr_sectors);
void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 8322e23f0d..ad559c62b1 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -438,13 +438,13 @@ BlockDirtyInfoList
*bdrv_query_dirty_bitmaps(BlockDriverState *bs)
}
/* Called within bdrv_dirty_bitmap_lock..unlock */
-int bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
- int64_t sector)
+bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
+ int64_t offset)
{
if (bitmap) {
- return hbitmap_get(bitmap->bitmap, sector);
+ return hbitmap_get(bitmap->bitmap, offset >> BDRV_SECTOR_BITS);
} else {
- return 0;
+ return false;
}
}
diff --git a/block/mirror.c b/block/mirror.c
index c5212d2c8d..545dfc50aa 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -361,8 +361,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_SECTOR_BITS)) {
+ !bdrv_get_dirty_locked(source, s->dirty_bitmap, next_offset)) {
break;
}
if (test_bit(next_chunk, s->in_flight_bitmap)) {
diff --git a/migration/block.c b/migration/block.c
index cbcadce168..f5bcf5505c 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -535,7 +535,8 @@ static int mig_save_device_dirty(QEMUFile *f,
BlkMigDevState *bmds,
blk_mig_unlock();
}
bdrv_dirty_bitmap_lock(bmds->dirty_bitmap);
- if (bdrv_get_dirty_locked(bs, bmds->dirty_bitmap, sector)) {
+ if (bdrv_get_dirty_locked(bs, bmds->dirty_bitmap,
+ sector * BDRV_SECTOR_SIZE)) {
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - sector;
} else {
--
2.13.6
- [Qemu-block] [PULL 07/54] dirty-bitmap: Change bdrv_dirty_bitmap_size() to report bytes, (continued)
- [Qemu-block] [PULL 07/54] dirty-bitmap: Change bdrv_dirty_bitmap_size() to report bytes, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 08/54] dirty-bitmap: Track bitmap size by bytes, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 10/54] qcow2: Switch sectors_covered_by_bitmap_cluster() to byte-based, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 11/54] dirty-bitmap: Set iterator start by offset, not sector, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 09/54] dirty-bitmap: Change bdrv_dirty_bitmap_*serialize*() to take bytes, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 12/54] dirty-bitmap: Change bdrv_dirty_iter_next() to report byte offset, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 16/54] mirror: Switch mirror_dirty_init() to byte-based iteration, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 15/54] dirty-bitmap: Change bdrv_[re]set_dirty_bitmap() to use bytes, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 13/54] dirty-bitmap: Change bdrv_get_dirty_count() to report bytes, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 17/54] qcow2: Switch qcow2_measure() to byte-based iteration, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 14/54] dirty-bitmap: Change bdrv_get_dirty_locked() to take bytes,
Kevin Wolf <=
- [Qemu-block] [PULL 19/54] qcow2: Switch store_bitmap_data() to byte-based iteration, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 18/54] qcow2: Switch load_bitmap_data() to byte-based iteration, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 20/54] dirty-bitmap: Switch bdrv_set_dirty() to bytes, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 21/54] dirty-bitmap: Convert internal hbitmap size/granularity, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 23/54] qemu-iotests: remove dead code, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 22/54] hw/block/onenand: Remove dead code block, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 24/54] qemu-iotests: get rid of AWK_PROG, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 25/54] qemu-iotests: move "check" code out of common.rc, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 26/54] qemu-iotests: cleanup and fix search for programs, Kevin Wolf, 2017/10/06
- [Qemu-block] [PULL 30/54] qemu-iotests: fix uninitialized variable, Kevin Wolf, 2017/10/06