From nobody Wed Nov 5 05:28:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529946300329407.06128356836837; Mon, 25 Jun 2018 10:05:00 -0700 (PDT) Received: from localhost ([::1]:48364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUvD-0004bC-Kv for importer@patchew.org; Mon, 25 Jun 2018 13:04:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUoK-0008M2-PZ for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:57:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXUoI-0006s4-QL for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:57:52 -0400 Received: from relay.sw.ru ([185.231.240.75]:44284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXUoI-0006qT-IP; Mon, 25 Jun 2018 12:57:50 -0400 Received: from msk-vpn.virtuozzo.com ([195.214.232.6] helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1fXUoE-00051E-3b; Mon, 25 Jun 2018 19:57:46 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 25 Jun 2018 19:57:45 +0300 Message-Id: <20180625165745.25259-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20180625165745.25259-1-vsementsov@virtuozzo.com> References: <20180625165745.25259-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 2/2] dirty-bitmap: fix double lock on bitmap enabling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, famz@redhat.com, quintela@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/dirty-bitmap.c | 3 ++- migration/block-dirty-bitmap.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 93744b3565..c9b8a6fd52 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -250,8 +250,9 @@ void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *b= itmap) /* Called with BQL taken. */ void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap) { + assert(bitmap->mutex =3D=3D 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); } =20 diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 3bafbbdc4c..477826330c 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -511,7 +511,7 @@ void dirty_bitmap_mig_before_vm_start(void) DirtyBitmapLoadBitmapState *b =3D item->data; =20 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, Dir= tyBitmapLoadState *s) if (enabled_bitmaps =3D=3D NULL) { /* in postcopy */ bdrv_reclaim_dirty_bitmap_locked(s->bs, s->bitmap, &error_abor= t); - bdrv_enable_dirty_bitmap(s->bitmap); + bdrv_enable_dirty_bitmap_locked(s->bitmap); } else { /* target not started, successor must be empty */ int64_t count =3D bdrv_get_dirty_count(s->bitmap); --=20 2.11.1