Skip to content

Commit 58f72b9

Browse files
Vladimir Sementsov-Ogievskiyjnsnow
Vladimir Sementsov-Ogievskiy
authored andcommitted
dirty-bitmap: fix double lock on bitmap enabling
Bitmap lock/unlock were added to bdrv_enable_dirty_bitmap in 8b1402c, 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. Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
1 parent 92bcea4 commit 58f72b9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

block/dirty-bitmap.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap)
250250
/* Called with BQL taken. */
251251
void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap)
252252
{
253+
assert(bitmap->mutex == bitmap->successor->mutex);
253254
qemu_mutex_lock(bitmap->mutex);
254-
bdrv_enable_dirty_bitmap(bitmap->successor);
255+
bdrv_enable_dirty_bitmap_locked(bitmap->successor);
255256
qemu_mutex_unlock(bitmap->mutex);
256257
}
257258

migration/block-dirty-bitmap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ void dirty_bitmap_mig_before_vm_start(void)
511511
DirtyBitmapLoadBitmapState *b = item->data;
512512

513513
if (b->migrated) {
514-
bdrv_enable_dirty_bitmap(b->bitmap);
514+
bdrv_enable_dirty_bitmap_locked(b->bitmap);
515515
} else {
516516
bdrv_dirty_bitmap_enable_successor(b->bitmap);
517517
}
@@ -547,7 +547,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *s)
547547
if (enabled_bitmaps == NULL) {
548548
/* in postcopy */
549549
bdrv_reclaim_dirty_bitmap_locked(s->bs, s->bitmap, &error_abort);
550-
bdrv_enable_dirty_bitmap(s->bitmap);
550+
bdrv_enable_dirty_bitmap_locked(s->bitmap);
551551
} else {
552552
/* target not started, successor must be empty */
553553
int64_t count = bdrv_get_dirty_count(s->bitmap);

0 commit comments

Comments
 (0)