Blame SOURCES/kvm-block-dirty-bitmap-explicitly-lock-bitmaps-with-succ.patch

7711c0
From dec8a19c9a45f060a9f20556672edeb61ecb6685 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 3 Apr 2019 18:18:44 +0200
7711c0
Subject: [PATCH 139/163] block/dirty-bitmap: explicitly lock bitmaps with
7711c0
 successors
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190403181857.9693-9-jsnow@redhat.com>
7711c0
Patchwork-id: 85410
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 08/21] block/dirty-bitmap: explicitly lock bitmaps with successors
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
Instead of implying a user_locked/busy status, make it explicit.
7711c0
Now, bitmaps in use by migration, NBD or backup operations
7711c0
are all treated the same way with the same code paths.
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: 20190223000614.13894-7-jsnow@redhat.com
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
(cherry picked from commit 21d2376f264bcaa1692bd71ab1f99b9b0ff5afbf)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/dirty-bitmap.c | 11 ++++++-----
7711c0
 1 file changed, 6 insertions(+), 5 deletions(-)
7711c0
7711c0
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
7711c0
index fa411f9..a495178 100644
7711c0
--- a/block/dirty-bitmap.c
7711c0
+++ b/block/dirty-bitmap.c
7711c0
@@ -50,7 +50,7 @@ struct BdrvDirtyBitmap {
7711c0
     HBitmap *meta;              /* Meta dirty bitmap */
7711c0
     bool qmp_locked;            /* Bitmap is locked, it can't be modified
7711c0
                                    through QMP */
7711c0
-    BdrvDirtyBitmap *successor; /* Anonymous child; implies user_locked state */
7711c0
+    BdrvDirtyBitmap *successor; /* Anonymous child, if any. */
7711c0
     char *name;                 /* Optional non-empty unique ID */
7711c0
     int64_t size;               /* Size of the bitmap, in bytes */
7711c0
     bool disabled;              /* Bitmap is disabled. It ignores all writes to
7711c0
@@ -188,10 +188,8 @@ bool bdrv_dirty_bitmap_has_successor(BdrvDirtyBitmap *bitmap)
7711c0
     return bitmap->successor;
7711c0
 }
7711c0
 
7711c0
-/* Both conditions disallow user-modification via QMP. */
7711c0
 bool bdrv_dirty_bitmap_user_locked(BdrvDirtyBitmap *bitmap) {
7711c0
-    return bdrv_dirty_bitmap_has_successor(bitmap) ||
7711c0
-           bdrv_dirty_bitmap_qmp_locked(bitmap);
7711c0
+    return bdrv_dirty_bitmap_qmp_locked(bitmap);
7711c0
 }
7711c0
 
7711c0
 void bdrv_dirty_bitmap_set_qmp_locked(BdrvDirtyBitmap *bitmap, bool qmp_locked)
7711c0
@@ -267,8 +265,9 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
7711c0
     child->disabled = bitmap->disabled;
7711c0
     bitmap->disabled = true;
7711c0
 
7711c0
-    /* Install the successor and freeze the parent */
7711c0
+    /* Install the successor and lock the parent */
7711c0
     bitmap->successor = child;
7711c0
+    bitmap->qmp_locked = true;
7711c0
     return 0;
7711c0
 }
7711c0
 
7711c0
@@ -323,6 +322,7 @@ BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,
7711c0
     bitmap->successor = NULL;
7711c0
     successor->persistent = bitmap->persistent;
7711c0
     bitmap->persistent = false;
7711c0
+    bitmap->qmp_locked = false;
7711c0
     bdrv_release_dirty_bitmap(bs, bitmap);
7711c0
 
7711c0
     return successor;
7711c0
@@ -352,6 +352,7 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BlockDriverState *bs,
7711c0
     }
7711c0
 
7711c0
     parent->disabled = successor->disabled;
7711c0
+    parent->qmp_locked = false;
7711c0
     bdrv_release_dirty_bitmap_locked(successor);
7711c0
     parent->successor = NULL;
7711c0
 
7711c0
-- 
7711c0
1.8.3.1
7711c0