From nobody Tue Feb 10 17:14:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1600766926; cv=none; d=zohomail.com; s=zohoarc; b=ZcUqKKhDG+iFw49U8iRWklRiVkHW+eC3doJhrJyKi6brvLZ3wiFyBWeKk2bIJ33R52uh7gmtU8aT2THRZKa4xQfHfKlxJ8DaN/+fNKLFeSMk/7TkkCZyc8bWoQT4P95yJ/FrYKyGfPG7r4SnyWPfMOxZxqBfbib0AQ0POCNH9tQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600766926; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mo6ecc9X3i23/WJn95SMzcbWz9ogA/Y9N4mqRkCqqVI=; b=d1i+MjzqsRXKAuTUCmYHqPwMcCliq+pXdXdBxC6PfXLCt3DcWghT7gleBpOrdfK0a0Id4esLiJ+cd/EqX6OL1k11JrHO43uJx4+8UvYjeTjIzKwzrs6hH8r8jXzwWxkFXi3lsHYdbGj3wOyniHSy15wx9gXPhWCMEPwFNhQvJQE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600766926396766.2420881722187; Tue, 22 Sep 2020 02:28:46 -0700 (PDT) Received: from localhost ([::1]:60652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKebN-0001U2-32 for importer@patchew.org; Tue, 22 Sep 2020 05:28:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKeW0-0002Ck-9L; Tue, 22 Sep 2020 05:23:12 -0400 Received: from proxmox-new.maurer-it.com ([212.186.127.180]:23413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKeVx-0005cY-90; Tue, 22 Sep 2020 05:23:11 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3EA55454AE; Tue, 22 Sep 2020 11:14:33 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: qemu-devel@nongnu.org Subject: [PATCH qemu 2/4] drive-mirror: add support for conditional and always bitmap sync modes Date: Tue, 22 Sep 2020 11:14:16 +0200 Message-Id: <20200922091418.53562-3-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200922091418.53562-1-f.gruenbichler@proxmox.com> References: <20200922091418.53562-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.186.127.180; envelope-from=f.gruenbichler@proxmox.com; helo=proxmox-new.maurer-it.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 05:14:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: John Snow Teach mirror two new tricks for using bitmaps: Always: no matter what, we synchronize the copy_bitmap back to the sync_bitmap. In effect, this allows us resume a failed mirror at a later date, since the target bdrv should be exactly in the state referenced by the bitmap. Conditional: On success only, we sync the bitmap. This is akin to incremental backup modes; we can use this bitmap to later refresh a successfully created mirror, or possibly re-try the whole failed mirror if we are able to rollback the target to the state before starting the mirror. Based on original work by John Snow. Signed-off-by: Fabian Gr=C3=BCnbichler --- block/mirror.c | 28 ++++++++++++++++++++-------- blockdev.c | 3 +++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index d64c8203ef..bc4f4563d9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -654,8 +654,6 @@ static int mirror_exit_common(Job *job) bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs); } =20 - bdrv_release_dirty_bitmap(s->dirty_bitmap); - /* Make sure that the source BDS doesn't go away during bdrv_replace_n= ode, * before we can call bdrv_drained_end */ bdrv_ref(src); @@ -755,6 +753,18 @@ static int mirror_exit_common(Job *job) blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort); blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort); =20 + if (s->sync_bitmap) { + if (s->bitmap_mode =3D=3D BITMAP_SYNC_MODE_ALWAYS || + (s->bitmap_mode =3D=3D BITMAP_SYNC_MODE_ON_SUCCESS && + job->ret =3D=3D 0 && ret =3D=3D 0)) { + /* Success; synchronize copy back to sync. */ + bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL); + bdrv_dirty_bitmap_merge_internal(s->sync_bitmap, s->dirty_bitm= ap, + NULL, true); + } + } + bdrv_release_dirty_bitmap(s->dirty_bitmap); + bs_opaque->job =3D NULL; =20 bdrv_drained_end(src); @@ -1592,10 +1602,6 @@ static BlockJob *mirror_start_job( " sync mode", MirrorSyncMode_str(sync_mode)); return NULL; - } else if (bitmap_mode !=3D BITMAP_SYNC_MODE_NEVER) { - error_setg(errp, - "Bitmap Sync Mode '%s' is not supported by Mirror", - BitmapSyncMode_str(bitmap_mode)); } } else if (bitmap) { error_setg(errp, @@ -1612,6 +1618,12 @@ static BlockJob *mirror_start_job( return NULL; } granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + + if (bitmap_mode !=3D BITMAP_SYNC_MODE_NEVER) { + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)= ) { + return NULL; + } + } } else if (granularity =3D=3D 0) { granularity =3D bdrv_get_default_bitmap_granularity(target); } @@ -1781,8 +1793,8 @@ static BlockJob *mirror_start_job( } =20 if (s->sync_mode =3D=3D MIRROR_SYNC_MODE_BITMAP) { - bdrv_merge_dirty_bitmap(s->dirty_bitmap, s->sync_bitmap, - NULL, &local_err); + bdrv_dirty_bitmap_merge_internal(s->dirty_bitmap, s->sync_bitmap, + NULL, true); if (local_err) { goto fail; } diff --git a/blockdev.c b/blockdev.c index 6baa1a33f5..0fd30a392d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3019,6 +3019,9 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) { return; } + } else if (has_bitmap_mode) { + error_setg(errp, "Cannot specify bitmap sync mode without a bitmap= "); + return; } =20 if (!has_replaces) { --=20 2.20.1