aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2019-07-29 16:35:55 -0400
committerJohn Snow <jsnow@redhat.com>2019-08-16 16:28:03 -0400
commit141cdcdf84a07c8f23f8b1c4e3c5ebb0669f7616 (patch)
tree6168718f4f5a2cba2b9ecc147d1290a5d6b74296 /block
parent0fff1f13718a80c12a26dfaee17bdeb45ce51459 (diff)
downloadqemu-141cdcdf84a07c8f23f8b1c4e3c5ebb0669f7616.zip
qemu-141cdcdf84a07c8f23f8b1c4e3c5ebb0669f7616.tar.gz
qemu-141cdcdf84a07c8f23f8b1c4e3c5ebb0669f7616.tar.bz2
block/backup: centralize copy_bitmap initialization
Just a few housekeeping changes that keeps the following commit easier to read; perform the initial copy_bitmap initialization in one place. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20190716000117.25219-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/backup.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/block/backup.c b/block/backup.c
index b04ab2d..305f9b3 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -451,16 +451,22 @@ static int coroutine_fn backup_loop(BackupBlockJob *job)
return ret;
}
-/* init copy_bitmap from sync_bitmap */
-static void backup_incremental_init_copy_bitmap(BackupBlockJob *job)
+static void backup_init_copy_bitmap(BackupBlockJob *job)
{
- bool ret = bdrv_dirty_bitmap_merge_internal(job->copy_bitmap,
- job->sync_bitmap,
- NULL, true);
- assert(ret);
+ bool ret;
+ uint64_t estimate;
+
+ if (job->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
+ ret = bdrv_dirty_bitmap_merge_internal(job->copy_bitmap,
+ job->sync_bitmap,
+ NULL, true);
+ assert(ret);
+ } else {
+ bdrv_set_dirty_bitmap(job->copy_bitmap, 0, job->len);
+ }
- job_progress_set_remaining(&job->common.job,
- bdrv_get_dirty_count(job->copy_bitmap));
+ estimate = bdrv_get_dirty_count(job->copy_bitmap);
+ job_progress_set_remaining(&job->common.job, estimate);
}
static int coroutine_fn backup_run(Job *job, Error **errp)
@@ -472,12 +478,7 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
QLIST_INIT(&s->inflight_reqs);
qemu_co_rwlock_init(&s->flush_rwlock);
- if (s->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
- backup_incremental_init_copy_bitmap(s);
- } else {
- bdrv_set_dirty_bitmap(s->copy_bitmap, 0, s->len);
- job_progress_set_remaining(job, s->len);
- }
+ backup_init_copy_bitmap(s);
s->before_write.notify = backup_before_write_notify;
bdrv_add_before_write_notifier(bs, &s->before_write);