Skip to content

Commit

Permalink
block/mirror: Refresh stale bitmap iterator cache
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
XanClic authored and kevmw committed Apr 20, 2016
1 parent 9c83625 commit f27a274
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions block/mirror.c
Original file line number Diff line number Diff line change
@@ -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++;
}

0 comments on commit f27a274

Please sign in to comment.