summaryrefslogtreecommitdiff
path: root/block-migration.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2010-11-12 16:07:50 -0200
committerKevin Wolf <kwolf@redhat.com>2010-11-24 17:31:06 +0100
commit62155e2b51e3c282ddc30adbb6d7b8d3bb7c386e (patch)
tree6ec145a5ba532f11162e4a73afc876613c44fde1 /block-migration.c
parent9063f81415f3518ef8206e74085c2a92c96890a0 (diff)
downloadqemu-62155e2b51e3c282ddc30adbb6d7b8d3bb7c386e.tar.gz
qemu-62155e2b51e3c282ddc30adbb6d7b8d3bb7c386e.tar.bz2
qemu-62155e2b51e3c282ddc30adbb6d7b8d3bb7c386e.zip
block migration: do not submit multiple AIOs for same sector (v2)
An old version of this patch was applied to master, so this contains the differences between v1 and v2. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block-migration.c')
-rw-r--r--block-migration.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/block-migration.c b/block-migration.c
index 3e66f49350..14753254d6 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -146,8 +146,7 @@ static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector)
{
int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK;
- if (bmds->aio_bitmap &&
- (sector << BDRV_SECTOR_BITS) < bdrv_getlength(bmds->bs)) {
+ if ((sector << BDRV_SECTOR_BITS) < bdrv_getlength(bmds->bs)) {
return !!(bmds->aio_bitmap[chunk / (sizeof(unsigned long) * 8)] &
(1UL << (chunk % (sizeof(unsigned long) * 8))));
} else {
@@ -169,13 +168,9 @@ static void bmds_set_aio_inflight(BlkMigDevState *bmds, int64_t sector_num,
bit = start % (sizeof(unsigned long) * 8);
val = bmds->aio_bitmap[idx];
if (set) {
- if (!(val & (1UL << bit))) {
- val |= 1UL << bit;
- }
+ val |= 1UL << bit;
} else {
- if (val & (1UL << bit)) {
- val &= ~(1UL << bit);
- }
+ val &= ~(1UL << bit);
}
bmds->aio_bitmap[idx] = val;
}
@@ -385,8 +380,9 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f,
int nr_sectors;
for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) {
- if (bmds_aio_inflight(bmds, sector))
+ if (bmds_aio_inflight(bmds, sector)) {
qemu_aio_flush();
+ }
if (bdrv_get_dirty(bmds->bs, sector)) {
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {