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

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