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

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