mirror of https://gitee.com/openkylin/qemu.git
dirty-bitmap: Change bdrv_get_dirty_locked() to take bytes
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 <eblake@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
9a46dba7b7
commit
3b5d4df0c6
|
@ -438,13 +438,13 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called within bdrv_dirty_bitmap_lock..unlock */
|
/* Called within bdrv_dirty_bitmap_lock..unlock */
|
||||||
int bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
|
bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
|
||||||
int64_t sector)
|
int64_t offset)
|
||||||
{
|
{
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
return hbitmap_get(bitmap->bitmap, sector);
|
return hbitmap_get(bitmap->bitmap, offset >> BDRV_SECTOR_BITS);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_offset = offset + nb_chunks * s->granularity;
|
||||||
int64_t next_chunk = next_offset / s->granularity;
|
int64_t next_chunk = next_offset / s->granularity;
|
||||||
if (next_offset >= s->bdev_length ||
|
if (next_offset >= s->bdev_length ||
|
||||||
!bdrv_get_dirty_locked(source, s->dirty_bitmap,
|
!bdrv_get_dirty_locked(source, s->dirty_bitmap, next_offset)) {
|
||||||
next_offset >> BDRV_SECTOR_BITS)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (test_bit(next_chunk, s->in_flight_bitmap)) {
|
if (test_bit(next_chunk, s->in_flight_bitmap)) {
|
||||||
|
|
|
@ -72,8 +72,8 @@ void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
|
||||||
/* Functions that require manual locking. */
|
/* Functions that require manual locking. */
|
||||||
void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap);
|
void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap);
|
||||||
void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap);
|
void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap);
|
||||||
int bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
|
bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
|
||||||
int64_t sector);
|
int64_t offset);
|
||||||
void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
||||||
int64_t cur_sector, int64_t nr_sectors);
|
int64_t cur_sector, int64_t nr_sectors);
|
||||||
void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
||||||
|
|
|
@ -535,7 +535,8 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
|
||||||
blk_mig_unlock();
|
blk_mig_unlock();
|
||||||
}
|
}
|
||||||
bdrv_dirty_bitmap_lock(bmds->dirty_bitmap);
|
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) {
|
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
|
||||||
nr_sectors = total_sectors - sector;
|
nr_sectors = total_sectors - sector;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue