summaryrefslogtreecommitdiffstats
path: root/block/mirror.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2016-04-20 00:59:48 +0200
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 20:03:49 -0600
commit6216fe9378a42cc4033f17837de14ad0697eb3b6 (patch)
tree61ebe91153630ec9b9156cddb6a57105ce466eff /block/mirror.c
parenta9ad7d5877cea3fd533dd9851ddca59c3a9aee66 (diff)
downloadhqemu-6216fe9378a42cc4033f17837de14ad0697eb3b6.zip
hqemu-6216fe9378a42cc4033f17837de14ad0697eb3b6.tar.gz
block/mirror: Refresh stale bitmap iterator cache
If the drive's dirty bitmap is dirtied while the mirror operation is running, the cache of the iterator used by the mirror code may become stale and not contain all dirty bits. This only becomes an issue if we are looking for contiguously dirty chunks on the drive. In that case, we can easily detect the discrepancy and just refresh the iterator if one occurs. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r--block/mirror.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/block/mirror.c b/block/mirror.c
index 2714a77..9df1fae 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -334,6 +334,11 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
}
hbitmap_next = hbitmap_iter_next(&s->hbi);
+ if (hbitmap_next > next_sector || hbitmap_next < 0) {
+ /* The bitmap iterator's cache is stale, refresh it */
+ bdrv_set_dirty_iter(&s->hbi, next_sector);
+ hbitmap_next = hbitmap_iter_next(&s->hbi);
+ }
assert(hbitmap_next == next_sector);
nb_chunks++;
}
OpenPOWER on IntegriCloud