fbe740
From 6c139a45537d021f6fd4287bd3c74cba06e6a264 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <6c139a45537d021f6fd4287bd3c74cba06e6a264@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Tue, 23 Jun 2020 12:23:47 +0200
fbe740
Subject: [PATCH] qemu: checkpoint: Don't chain bitmaps for checkpoints
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Chaining bitmaps for checkpoints (disabling the active one and creating
fbe740
a new) severely overcomplicated all operations in regards to bitmaps.
fbe740
fbe740
Specifically it requires us re-matching the on-disk state to the
fbe740
internal metadata and in case of merging during block jobs it makes it
fbe740
almost impossible to cover all corner cases.
fbe740
fbe740
Since the checkpoints and incremental backups were not yet enabled,
fbe740
let's change the design to keep one bitmap per checkpoint. In case of
fbe740
layered snapshots this will be filled in by using dirty-bitmap-populate.
fbe740
fbe740
Finally the main reason for this unnecessary complexity was the fear
fbe740
that qemu's performance could degrade. In the end I think that
fbe740
addressing the performance issue will be better done in qemu (e.g by
fbe740
keeping an internal bitmap updated with changes and merging it
fbe740
periodically back to the real bitmaps. QEMU writes out changes to disk
fbe740
at shutdown so consistency is not a problem).
fbe740
fbe740
Removing the relationships between bitmaps frees us from complex
fbe740
handling and also makes all the surrounding code more robust as one
fbe740
broken bitmap doesn't necessarily invalidate whole chains of backups.
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Eric Blake <eblake@redhat.com>
fbe740
(cherry picked from commit 1f92aa454aa3b04ece9f7479d517bf08ba547f0a)
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
fbe740
Message-Id: <a863b2015f72690ebd90fd518e8163e194909214.1592906423.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_checkpoint.c | 21 +--------------------
fbe740
 1 file changed, 1 insertion(+), 20 deletions(-)
fbe740
fbe740
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
fbe740
index 34cf122eb3..9762a3eb9d 100644
fbe740
--- a/src/qemu/qemu_checkpoint.c
fbe740
+++ b/src/qemu/qemu_checkpoint.c
fbe740
@@ -460,7 +460,6 @@ qemuCheckpointPrepare(virQEMUDriverPtr driver,
fbe740
 static int
fbe740
 qemuCheckpointAddActions(virDomainObjPtr vm,
fbe740
                          virJSONValuePtr actions,
fbe740
-                         virDomainMomentObjPtr old_current,
fbe740
                          virDomainCheckpointDefPtr def)
fbe740
 {
fbe740
     size_t i;
fbe740
@@ -468,7 +467,6 @@ qemuCheckpointAddActions(virDomainObjPtr vm,
fbe740
     for (i = 0; i < def->ndisks; i++) {
fbe740
         virDomainCheckpointDiskDef *chkdisk = &def->disks[i];
fbe740
         virDomainDiskDefPtr domdisk = virDomainDiskByTarget(vm->def, chkdisk->name);
fbe740
-        virDomainCheckpointDiskDef *parentchkdisk = NULL;
fbe740
 
fbe740
         /* checkpoint definition validator mandates that the corresponding
fbe740
          * domdisk should exist */
fbe740
@@ -479,23 +477,6 @@ qemuCheckpointAddActions(virDomainObjPtr vm,
fbe740
         if (qemuMonitorTransactionBitmapAdd(actions, domdisk->src->nodeformat,
fbe740
                                             chkdisk->bitmap, true, false, 0) < 0)
fbe740
             return -1;
fbe740
-
fbe740
-        /* We only want one active bitmap for a disk along the
fbe740
-         * checkpoint chain, then later differential backups will
fbe740
-         * merge the bitmaps (only one active) between the bounding
fbe740
-         * checkpoint and the leaf checkpoint.  If the same disks are
fbe740
-         * involved in each checkpoint, this search terminates in one
fbe740
-         * iteration; but it is also possible to have to search
fbe740
-         * further than the immediate parent to find another
fbe740
-         * checkpoint with a bitmap on the same disk.  */
fbe740
-        if ((parentchkdisk = qemuCheckpointFindActiveDiskInParent(vm, old_current,
fbe740
-                                                                  chkdisk->name))) {
fbe740
-
fbe740
-            if (qemuMonitorTransactionBitmapDisable(actions,
fbe740
-                                                    domdisk->src->nodeformat,
fbe740
-                                                    parentchkdisk->bitmap) < 0)
fbe740
-                return -1;
fbe740
-        }
fbe740
     }
fbe740
     return 0;
fbe740
 }
fbe740
@@ -544,7 +525,7 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver,
fbe740
 
fbe740
     tmpactions = virJSONValueNewArray();
fbe740
 
fbe740
-    if (qemuCheckpointAddActions(vm, tmpactions, parent, *def) < 0)
fbe740
+    if (qemuCheckpointAddActions(vm, tmpactions, *def) < 0)
fbe740
         return -1;
fbe740
 
fbe740
     if (!(*chk = virDomainCheckpointAssignDef(vm->checkpoints, *def)))
fbe740
-- 
fbe740
2.27.0
fbe740