Skip to contentSkip to conversation

Bitmaps patches

GIT PULL Applied John Snow 2 participants 4 messages Jul 4, 2018 – Jul 5, 2018 Block layer

lore
Share & tools
lore
author
#1 lore raw

[Qemu-devel] [PULL 1/2] block/dirty-bitmap: add bdrv_enable_dirty_bitmap_locked

In reply to John Snow

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Add _locked version of bdrv_enable_dirty_bitmap, to fix dirty bitmap migration in the following patch.

Message-id: [email protected]

---
 block/dirty-bitmap.c         | 9 +++++++--
 include/block/dirty-bitmap.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)
block/dirty-bitmap.c +7 -2
index db1782ec1f..93744b3565 100644
@@ -241,6 +241,12 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
     return 0;
 }
 
+void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap)
+{
+    assert(!bdrv_dirty_bitmap_frozen(bitmap));
+    bitmap->disabled = false;
+}
+
 /* Called with BQL taken. */
 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap)
 {
@@ -424,8 +430,7 @@ void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
 {
     bdrv_dirty_bitmap_lock(bitmap);
-    assert(!bdrv_dirty_bitmap_frozen(bitmap));
-    bitmap->disabled = false;
+    bdrv_enable_dirty_bitmap_locked(bitmap);
     bdrv_dirty_bitmap_unlock(bitmap);
 }
 
include/block/dirty-bitmap.h +1 -0
index 288dc6adb6..259bd27c40 100644
@@ -32,6 +32,7 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
                                          Error **errp);
 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
+void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap);
 BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs);
 uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs);
 uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap);
Signature · 1 line
2.14.4
author
#2 lore raw

[Qemu-devel] [PULL 2/2] dirty-bitmap: fix double lock on bitmap enabling

In reply to John Snow

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Bitmap lock/unlock were added to bdrv_enable_dirty_bitmap in 8b1402ce80d, but some places were not updated correspondingly, which leads to trying to take this lock twice, which is dead-lock. Fix this.

Actually, iotest 199 (about dirty bitmap postcopy migration) is broken now, and this fixes it.

Message-id: [email protected]

---
 block/dirty-bitmap.c           | 3 ++-
 migration/block-dirty-bitmap.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
block/dirty-bitmap.c +2 -1
index 93744b3565..c9b8a6fd52 100644
@@ -250,8 +250,9 @@ void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap)
 /* Called with BQL taken. */
 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap)
 {
+    assert(bitmap->mutex == bitmap->successor->mutex);
     qemu_mutex_lock(bitmap->mutex);
-    bdrv_enable_dirty_bitmap(bitmap->successor);
+    bdrv_enable_dirty_bitmap_locked(bitmap->successor);
     qemu_mutex_unlock(bitmap->mutex);
 }
 
migration/block-dirty-bitmap.c +2 -2
index 3bafbbdc4c..477826330c 100644
@@ -511,7 +511,7 @@ void dirty_bitmap_mig_before_vm_start(void)
         DirtyBitmapLoadBitmapState *b = item->data;
 
         if (b->migrated) {
-            bdrv_enable_dirty_bitmap(b->bitmap);
+            bdrv_enable_dirty_bitmap_locked(b->bitmap);
         } else {
             bdrv_dirty_bitmap_enable_successor(b->bitmap);
         }
@@ -547,7 +547,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *s)
         if (enabled_bitmaps == NULL) {
             /* in postcopy */
             bdrv_reclaim_dirty_bitmap_locked(s->bs, s->bitmap, &error_abort);
-            bdrv_enable_dirty_bitmap(s->bitmap);
+            bdrv_enable_dirty_bitmap_locked(s->bitmap);
         } else {
             /* target not started, successor must be empty */
             int64_t count = bdrv_get_dirty_count(s->bitmap);
Signature · 1 line
2.14.4

John Snow

author
#0 lore raw

The following changes since commit 79c2b203a932db5882a3f328db53e5a448cd47f9:

Merge remote-tracking branch 'remotes/kraxel/tags/vga-20180703-pull-request' into staging (2018-07-03 21:09:27 +0100)

are available in the Git repository at:

https://github.com/jnsnow/qemu.git tags/bitmaps-pull-request

for you to fetch changes up to 58f72b965e9e1820d246329461216c4d13140122:

dirty-bitmap: fix double lock on bitmap enabling (2018-07-04 02:12:49 -0400)

----------------------------------------------------------------
Pull request

----------------------------------------------------------------

Vladimir Sementsov-Ogievskiy (2):
block/dirty-bitmap: add bdrv_enable_dirty_bitmap_locked
dirty-bitmap: fix double lock on bitmap enabling

 block/dirty-bitmap.c           | 12 +++++++++---
 include/block/dirty-bitmap.h   |  1 +
 migration/block-dirty-bitmap.c |  4 ++--
 3 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.4
#3 lore raw
Quoted 8 lines · John Snow

The following changes since commit 79c2b203a932db5882a3f328db53e5a448cd47f9:

Merge remote-tracking branch 'remotes/kraxel/tags/vga-20180703-pull-request' into staging (2018-07-03 21:09:27 +0100)

are available in the Git repository at:

https://github.com/jnsnow/qemu.git tags/bitmaps-pull-request

Quoted 9 lines

for you to fetch changes up to 58f72b965e9e1820d246329461216c4d13140122:

dirty-bitmap: fix double lock on bitmap enabling (2018-07-04 02:12:49 -0400)

----------------------------------------------------------------
Pull request

----------------------------------------------------------------

Applied, thanks.

-- PMM