Received: from eggs.gnu.org ([2001:4830:134:3::10]:36061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpmCl-0008Uf-Ie for qemu-devel@nongnu.org; Fri, 23 Oct 2015 19:57:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpmCk-0001OY-DH for qemu-devel@nongnu.org; Fri, 23 Oct 2015 19:57:03 -0400 From: John Snow Date: Fri, 23 Oct 2015 19:56:42 -0400 Message-Id: <1445644612-12702-5-git-send-email-jsnow@redhat.com> In-Reply-To: <1445644612-12702-1-git-send-email-jsnow@redhat.com> References: <1445644612-12702-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH v10 04/14] backup: Extract dirty bitmap handling as a separate function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: vsementsov@virtuozzo.com, famz@redhat.com, John Snow , armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com From: Fam Zheng This will be reused by the coming new transactional completion code. Signed-off-by: Fam Zheng Reviewed-by: John Snow Reviewed-by: Max Reitz Signed-off-by: John Snow --- block/backup.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/block/backup.c b/block/backup.c index 5696431..8b92ed1 100644 --- a/block/backup.c +++ b/block/backup.c @@ -218,6 +218,22 @@ static void backup_iostatus_reset(BlockJob *job) bdrv_iostatus_reset(s->target); } +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, @@ -438,16 +454,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); -- 2.4.3