Commit b976ea3c authored by Fam Zheng's avatar Fam Zheng Committed by Kevin Wolf
Browse files

backup: Extract dirty bitmap handling as a separate function



This will be reused by the coming new transactional completion code.

Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
Message-id: 1446765200-3054-5-git-send-email-jsnow@redhat.com
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 50f43f0f
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -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);