aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2015-11-05 18:13:10 -0500
committerKevin Wolf <kwolf@redhat.com>2015-11-12 16:22:43 +0100
commitb976ea3cf591ac994cc17dcf0fc550c9aa9c0f5d (patch)
tree156d3d88136c183e8688a084b2cc0321589f1b43 /block
parent50f43f0ff9a640b901b2657492d642e14a57bd4d (diff)
downloadqemu-b976ea3cf591ac994cc17dcf0fc550c9aa9c0f5d.zip
qemu-b976ea3cf591ac994cc17dcf0fc550c9aa9c0f5d.tar.gz
qemu-b976ea3cf591ac994cc17dcf0fc550c9aa9c0f5d.tar.bz2
backup: Extract dirty bitmap handling as a separate function
This will be reused by the coming new transactional completion code. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1446765200-3054-5-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/backup.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/block/backup.c b/block/backup.c
index ec01db8..f7fcb99 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -221,6 +221,22 @@ static void backup_iostatus_reset(BlockJob *job)
}
}
+static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
+{
+ BdrvDirtyBitmap *bm;
+ BlockDriverState *bs = job->common.bs;
+
+ if (ret < 0 || block_job_is_cancelled(&job->common)) {
+ /* Merge the successor back into the parent, delete nothing. */
+ bm = bdrv_reclaim_dirty_bitmap(bs, job->sync_bitmap, NULL);
+ assert(bm);
+ } else {
+ /* Everything is fine, delete this bitmap and install the backup. */
+ bm = bdrv_dirty_bitmap_abdicate(bs, job->sync_bitmap, NULL);
+ assert(bm);
+ }
+}
+
static const BlockJobDriver backup_job_driver = {
.instance_size = sizeof(BackupBlockJob),
.job_type = BLOCK_JOB_TYPE_BACKUP,
@@ -443,16 +459,7 @@ static void coroutine_fn backup_run(void *opaque)
qemu_co_rwlock_unlock(&job->flush_rwlock);
if (job->sync_bitmap) {
- BdrvDirtyBitmap *bm;
- if (ret < 0 || block_job_is_cancelled(&job->common)) {
- /* Merge the successor back into the parent, delete nothing. */
- bm = bdrv_reclaim_dirty_bitmap(bs, job->sync_bitmap, NULL);
- assert(bm);
- } else {
- /* Everything is fine, delete this bitmap and install the backup. */
- bm = bdrv_dirty_bitmap_abdicate(bs, job->sync_bitmap, NULL);
- assert(bm);
- }
+ backup_cleanup_sync_bitmap(job, ret);
}
hbitmap_free(job->bitmap);