From nobody Mon Apr 14 05:06:02 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513608246490123.19962999644815; Mon, 18 Dec 2017 06:44:06 -0800 (PST) Received: from localhost ([::1]:41415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwe9-0004UY-CT for importer@patchew.org; Mon, 18 Dec 2017 09:44:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwWm-0006Zl-R0 for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:36:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQwWj-00070X-0X for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:36:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eQwWi-0006zk-Ql for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:36:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D90B15F7B1; Mon, 18 Dec 2017 14:36:19 +0000 (UTC) Received: from localhost (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5850A84D16; Mon, 18 Dec 2017 14:36:17 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 18 Dec 2017 14:35:14 +0000 Message-Id: <20171218143530.12082-8-stefanha@redhat.com> In-Reply-To: <20171218143530.12082-1-stefanha@redhat.com> References: <20171218143530.12082-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 18 Dec 2017 14:36:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/23] blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean() 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: Peter Maydell , Stefan Hajnoczi 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" bdrv_unref() requires the AioContext lock because bdrv_flush() uses BDRV_POLL_WHILE(), which assumes the AioContext is currently held. If BDRV_POLL_WHILE() runs without AioContext held the pthread_mutex_unlock() call in aio_context_release() fails. This patch moves bdrv_unref() into the AioContext locked region to solve the following pthread_mutex_unlock() failure: #0 0x00007f566181969b in raise () at /lib64/libc.so.6 #1 0x00007f566181b3b1 in abort () at /lib64/libc.so.6 #2 0x00005592cd590458 in error_exit (err=3D, msg=3Dmsg@en= try=3D0x5592cdaf6d60 <__func__.23977> "qemu_mutex_unlock") at util/qemu-thr= ead-posix.c:36 #3 0x00005592cd96e738 in qemu_mutex_unlock (mutex=3Dmutex@entry=3D0x5592= ce9505e0) at util/qemu-thread-posix.c:96 #4 0x00005592cd969b69 in aio_context_release (ctx=3Dctx@entry=3D0x5592ce= 950580) at util/async.c:507 #5 0x00005592cd8ead78 in bdrv_flush (bs=3Dbs@entry=3D0x5592cfa87210) at = block/io.c:2478 #6 0x00005592cd89df30 in bdrv_close (bs=3D0x5592cfa87210) at block.c:3207 #7 0x00005592cd89df30 in bdrv_delete (bs=3D0x5592cfa87210) at block.c:33= 95 #8 0x00005592cd89df30 in bdrv_unref (bs=3D0x5592cfa87210) at block.c:4418 #9 0x00005592cd6b7f86 in qmp_transaction (dev_list=3D, ha= s_props=3D, props=3D, errp=3Derrp@entry=3D0x7= ffe4a1fc9d8) at blockdev.c:2308 Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Eric Blake Message-id: 20171206144550.22295-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 56a6b24a0b..3c8d994ced 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1812,8 +1812,8 @@ static void external_snapshot_clean(BlkActionState *c= ommon) DO_UPCAST(ExternalSnapshotState, common, comm= on); if (state->aio_context) { bdrv_drained_end(state->old_bs); - aio_context_release(state->aio_context); bdrv_unref(state->new_bs); + aio_context_release(state->aio_context); } } =20 --=20 2.14.3