Blame SOURCES/kvm-dirty-bitmap-fix-double-lock-on-bitmap-enabling.patch

ae23c9
From c2d0ba193251782ce258dff254b00848bfc3de5a Mon Sep 17 00:00:00 2001
ae23c9
From: John Snow <jsnow@redhat.com>
ae23c9
Date: Wed, 18 Jul 2018 22:54:43 +0200
ae23c9
Subject: [PATCH 225/268] dirty-bitmap: fix double lock on bitmap enabling
ae23c9
ae23c9
RH-Author: John Snow <jsnow@redhat.com>
ae23c9
Message-id: <20180718225511.14878-8-jsnow@redhat.com>
ae23c9
Patchwork-id: 81403
ae23c9
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 07/35] dirty-bitmap: fix double lock on bitmap enabling
ae23c9
Bugzilla: 1207657
ae23c9
RH-Acked-by: Eric Blake <eblake@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
ae23c9
Bitmap lock/unlock were added to bdrv_enable_dirty_bitmap in
ae23c9
8b1402ce80d, but some places were not updated correspondingly, which
ae23c9
leads to trying to take this lock twice, which is dead-lock. Fix this.
ae23c9
ae23c9
Actually, iotest 199 (about dirty bitmap postcopy migration) is broken
ae23c9
now, and this fixes it.
ae23c9
ae23c9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
Message-id: 20180625165745.25259-3-vsementsov@virtuozzo.com
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
(cherry picked from commit 58f72b965e9e1820d246329461216c4d13140122)
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/dirty-bitmap.c           | 3 ++-
ae23c9
 migration/block-dirty-bitmap.c | 4 ++--
ae23c9
 2 files changed, 4 insertions(+), 3 deletions(-)
ae23c9
ae23c9
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
ae23c9
index 4d6ae8b..f580c1a 100644
ae23c9
--- a/block/dirty-bitmap.c
ae23c9
+++ b/block/dirty-bitmap.c
ae23c9
@@ -259,8 +259,9 @@ void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap)
ae23c9
 /* Called with BQL taken. */
ae23c9
 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap)
ae23c9
 {
ae23c9
+    assert(bitmap->mutex == bitmap->successor->mutex);
ae23c9
     qemu_mutex_lock(bitmap->mutex);
ae23c9
-    bdrv_enable_dirty_bitmap(bitmap->successor);
ae23c9
+    bdrv_enable_dirty_bitmap_locked(bitmap->successor);
ae23c9
     qemu_mutex_unlock(bitmap->mutex);
ae23c9
 }
ae23c9
 
ae23c9
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
ae23c9
index dd04f10..abba0b6 100644
ae23c9
--- a/migration/block-dirty-bitmap.c
ae23c9
+++ b/migration/block-dirty-bitmap.c
ae23c9
@@ -511,7 +511,7 @@ void dirty_bitmap_mig_before_vm_start(void)
ae23c9
         DirtyBitmapLoadBitmapState *b = item->data;
ae23c9
 
ae23c9
         if (b->migrated) {
ae23c9
-            bdrv_enable_dirty_bitmap(b->bitmap);
ae23c9
+            bdrv_enable_dirty_bitmap_locked(b->bitmap);
ae23c9
         } else {
ae23c9
             bdrv_dirty_bitmap_enable_successor(b->bitmap);
ae23c9
         }
ae23c9
@@ -547,7 +547,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *s)
ae23c9
         if (enabled_bitmaps == NULL) {
ae23c9
             /* in postcopy */
ae23c9
             bdrv_reclaim_dirty_bitmap_locked(s->bs, s->bitmap, &error_abort);
ae23c9
-            bdrv_enable_dirty_bitmap(s->bitmap);
ae23c9
+            bdrv_enable_dirty_bitmap_locked(s->bitmap);
ae23c9
         } else {
ae23c9
             /* target not started, successor must be empty */
ae23c9
             int64_t count = bdrv_get_dirty_count(s->bitmap);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9