Blame SOURCES/kvm-block-dirty-bitmaps-add-inconsistent-bit.patch

7711c0
From a955ea9fa72ac1a0e21b66d0958e582fbbc3f716 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 3 Apr 2019 18:18:49 +0200
7711c0
Subject: [PATCH 144/163] block/dirty-bitmaps: add inconsistent bit
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190403181857.9693-14-jsnow@redhat.com>
7711c0
Patchwork-id: 85419
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 13/21] block/dirty-bitmaps: add inconsistent bit
7711c0
Bugzilla: 1677073
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
7711c0
7711c0
Add an inconsistent bit to dirty-bitmaps that allows us to report a bitmap as
7711c0
persistent but potentially inconsistent, i.e. if we find bitmaps on a qcow2
7711c0
that have been marked as "in use".
7711c0
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Message-id: 20190301191545.8728-2-jsnow@redhat.com
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
(cherry picked from commit b0f455599d0f092abc11aa3daba693be1453d29a)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/dirty-bitmap.c         | 20 ++++++++++++++++++++
7711c0
 include/block/dirty-bitmap.h |  2 ++
7711c0
 qapi/block-core.json         | 13 +++++++++----
7711c0
 3 files changed, 31 insertions(+), 4 deletions(-)
7711c0
7711c0
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
7711c0
index e090237..096c1b7 100644
7711c0
--- a/block/dirty-bitmap.c
7711c0
+++ b/block/dirty-bitmap.c
7711c0
@@ -46,6 +46,9 @@ struct BdrvDirtyBitmap {
7711c0
                                    and this bitmap must remain unchanged while
7711c0
                                    this flag is set. */
7711c0
     bool persistent;            /* bitmap must be saved to owner disk image */
7711c0
+    bool inconsistent;          /* bitmap is persistent, but inconsistent.
7711c0
+                                   It cannot be used at all in any way, except
7711c0
+                                   a QMP user can remove it. */
7711c0
     bool migration;             /* Bitmap is selected for migration, it should
7711c0
                                    not be stored on the next inactivation
7711c0
                                    (persistent flag doesn't matter until next
7711c0
@@ -465,6 +468,8 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
7711c0
         info->recording = bdrv_dirty_bitmap_recording(bm);
7711c0
         info->busy = bdrv_dirty_bitmap_busy(bm);
7711c0
         info->persistent = bm->persistent;
7711c0
+        info->has_inconsistent = bm->inconsistent;
7711c0
+        info->inconsistent = bm->inconsistent;
7711c0
         entry->value = info;
7711c0
         *plist = entry;
7711c0
         plist = &entry->next;
7711c0
@@ -713,6 +718,16 @@ void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap, bool persistent)
7711c0
 }
7711c0
 
7711c0
 /* Called with BQL taken. */
7711c0
+void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap)
7711c0
+{
7711c0
+    qemu_mutex_lock(bitmap->mutex);
7711c0
+    assert(bitmap->persistent == true);
7711c0
+    bitmap->inconsistent = true;
7711c0
+    bitmap->disabled = true;
7711c0
+    qemu_mutex_unlock(bitmap->mutex);
7711c0
+}
7711c0
+
7711c0
+/* Called with BQL taken. */
7711c0
 void bdrv_dirty_bitmap_set_migration(BdrvDirtyBitmap *bitmap, bool migration)
7711c0
 {
7711c0
     qemu_mutex_lock(bitmap->mutex);
7711c0
@@ -725,6 +740,11 @@ bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap)
7711c0
     return bitmap->persistent && !bitmap->migration;
7711c0
 }
7711c0
 
7711c0
+bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap *bitmap)
7711c0
+{
7711c0
+    return bitmap->inconsistent;
7711c0
+}
7711c0
+
7711c0
 bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs)
7711c0
 {
7711c0
     BdrvDirtyBitmap *bm;
7711c0
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
7711c0
index ba8477b..bd1b647 100644
7711c0
--- a/include/block/dirty-bitmap.h
7711c0
+++ b/include/block/dirty-bitmap.h
7711c0
@@ -68,6 +68,7 @@ void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
7711c0
 void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value);
7711c0
 void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
7711c0
                                        bool persistent);
7711c0
+void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap);
7711c0
 void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy);
7711c0
 void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
7711c0
                              HBitmap **backup, Error **errp);
7711c0
@@ -91,6 +92,7 @@ bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);
7711c0
 bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
7711c0
 bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
7711c0
 bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap);
7711c0
+bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap *bitmap);
7711c0
 bool bdrv_dirty_bitmap_busy(BdrvDirtyBitmap *bitmap);
7711c0
 bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
7711c0
 BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
7711c0
diff --git a/qapi/block-core.json b/qapi/block-core.json
7711c0
index 98bd3a8..92a42ef 100644
7711c0
--- a/qapi/block-core.json
7711c0
+++ b/qapi/block-core.json
7711c0
@@ -468,15 +468,20 @@
7711c0
 #        and cannot be modified via QMP or used by another operation.
7711c0
 #        Replaces `locked` and `frozen` statuses. (since 4.0)
7711c0
 #
7711c0
-# @persistent: true if the bitmap will eventually be flushed to persistent
7711c0
-#              storage (since 4.0)
7711c0
+# @persistent: true if the bitmap was stored on disk, is scheduled to be stored
7711c0
+#              on disk, or both. (since 4.0)
7711c0
+#
7711c0
+# @inconsistent: true if this is a persistent bitmap that was improperly
7711c0
+#                stored. Implies @persistent to be true; @recording and
7711c0
+#                @busy to be false. This bitmap cannot be used. To remove
7711c0
+#                it, use @block-dirty-bitmap-remove. (Since 4.0)
7711c0
 #
7711c0
 # Since: 1.3
7711c0
 ##
7711c0
 { 'struct': 'BlockDirtyInfo',
7711c0
   'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
7711c0
-           'recording': 'bool', 'busy': 'bool',
7711c0
-           'status': 'DirtyBitmapStatus', 'persistent': 'bool' } }
7711c0
+           'recording': 'bool', 'busy': 'bool', 'status': 'DirtyBitmapStatus',
7711c0
+           'persistent': 'bool', '*inconsistent': 'bool' } }
7711c0
 
7711c0
 ##
7711c0
 # @Qcow2BitmapInfoFlags:
7711c0
-- 
7711c0
1.8.3.1
7711c0