From patchwork Thu Jul 30 06:39:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 501986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CE32D1409B7 for ; Thu, 30 Jul 2015 16:40:34 +1000 (AEST) Received: from localhost ([::1]:38166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKhW4-00048V-QI for incoming@patchwork.ozlabs.org; Thu, 30 Jul 2015 02:40:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKhVW-00032N-D0 for qemu-devel@nongnu.org; Thu, 30 Jul 2015 02:39:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKhVV-0000c3-1f for qemu-devel@nongnu.org; Thu, 30 Jul 2015 02:39:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKhVU-0000bj-Tb for qemu-devel@nongnu.org; Thu, 30 Jul 2015 02:39:56 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8BBF6A0B7B; Thu, 30 Jul 2015 06:39:56 +0000 (UTC) Received: from ad.nay.redhat.com. (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6U6dU9x016711; Thu, 30 Jul 2015 02:39:51 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 30 Jul 2015 14:39:20 +0800 Message-Id: <1438238370-16212-5-git-send-email-famz@redhat.com> In-Reply-To: <1438238370-16212-1-git-send-email-famz@redhat.com> References: <1438238370-16212-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , famz@redhat.com, John Snow , Jeff Cody , Max Reitz , vsementsov@parallels.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v4 04/14] backup: Extract dirty bitmap handling as a separate function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This will be reused by the coming new transactional completion code. Signed-off-by: Fam Zheng Reviewed-by: John Snow Reviewed-by: Max Reitz --- block/backup.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/block/backup.c b/block/backup.c index 965654d..9776d9c 100644 --- a/block/backup.c +++ b/block/backup.c @@ -210,6 +210,21 @@ 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), @@ -430,16 +445,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);