From nobody Sun Apr 13 18:04:24 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538415583755188.68622314412482; Mon, 1 Oct 2018 10:39:43 -0700 (PDT) Received: from localhost ([::1]:39935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g72AY-0000ck-Pp for importer@patchew.org; Mon, 01 Oct 2018 13:39:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g71rG-0002c6-Ab for qemu-devel@nongnu.org; Mon, 01 Oct 2018 13:19:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g71rD-0007MD-91 for qemu-devel@nongnu.org; Mon, 01 Oct 2018 13:19:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42638) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g71r8-0007EM-SD; Mon, 01 Oct 2018 13:19:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1995EA6DFE; Mon, 1 Oct 2018 17:19:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-246.ams2.redhat.com [10.36.116.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC14679435; Mon, 1 Oct 2018 17:19:36 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 1 Oct 2018 19:19:00 +0200 Message-Id: <20181001171901.11004-23-kwolf@redhat.com> In-Reply-To: <20181001171901.11004-1-kwolf@redhat.com> References: <20181001171901.11004-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 01 Oct 2018 17:19:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 22/23] test-replication: Lock AioContext around blk_unref() 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, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Recently, the test case has started failing because some job related functions want to drop the AioContext lock even though it hasn't been taken: (gdb) bt #0 0x00007f51c067c9fb in raise () from /lib64/libc.so.6 #1 0x00007f51c067e77d in abort () from /lib64/libc.so.6 #2 0x0000558c9d5dde7b in error_exit (err=3D, msg=3Dmsg@= entry=3D0x558c9d6fe120 <__func__.18373> "qemu_mutex_unlock_impl") at util/q= emu-thread-posix.c:36 #3 0x0000558c9d6b5263 in qemu_mutex_unlock_impl (mutex=3Dmutex@entry= =3D0x558c9f3999a0, file=3Dfile@entry=3D0x558c9d6fd36f "util/async.c", line= =3Dline@entry=3D516) at util/qemu-thread-posix.c:96 #4 0x0000558c9d6b0565 in aio_context_release (ctx=3Dctx@entry=3D0x558c= 9f399940) at util/async.c:516 #5 0x0000558c9d5eb3da in job_completed_txn_abort (job=3D0x558c9f68e640= ) at job.c:738 #6 0x0000558c9d5eb227 in job_finish_sync (job=3D0x558c9f68e640, finish= =3Dfinish@entry=3D0x558c9d5eb8d0 , errp=3Derrp@entry=3D0x0)= at job.c:986 #7 0x0000558c9d5eb8ee in job_cancel_sync (job=3D) at jo= b.c:941 #8 0x0000558c9d64d853 in replication_close (bs=3D) at b= lock/replication.c:148 #9 0x0000558c9d5e5c9f in bdrv_close (bs=3D0x558c9f41b020) at block.c:3= 420 #10 bdrv_delete (bs=3D0x558c9f41b020) at block.c:3629 #11 bdrv_unref (bs=3D0x558c9f41b020) at block.c:4685 #12 0x0000558c9d62a3f3 in blk_remove_bs (blk=3Dblk@entry=3D0x558c9f42a7= c0) at block/block-backend.c:783 #13 0x0000558c9d62a667 in blk_delete (blk=3D0x558c9f42a7c0) at block/bl= ock-backend.c:402 #14 blk_unref (blk=3D0x558c9f42a7c0) at block/block-backend.c:457 #15 0x0000558c9d5dfcea in test_secondary_stop () at tests/test-replicat= ion.c:478 #16 0x00007f51c1f13178 in g_test_run_suite_internal () from /lib64/libg= lib-2.0.so.0 #17 0x00007f51c1f1337b in g_test_run_suite_internal () from /lib64/libg= lib-2.0.so.0 #18 0x00007f51c1f1337b in g_test_run_suite_internal () from /lib64/libg= lib-2.0.so.0 #19 0x00007f51c1f13552 in g_test_run_suite () from /lib64/libglib-2.0.s= o.0 #20 0x00007f51c1f13571 in g_test_run () from /lib64/libglib-2.0.so.0 #21 0x0000558c9d5de31f in main (argc=3D, argv=3D) at tests/test-replication.c:581 It is yet unclear whether this should really be considered a bug in the test case or whether blk_unref() should work for callers that haven't taken the AioContext lock, but in order to fix the build tests quickly, just take the AioContext lock around blk_unref(). Signed-off-by: Kevin Wolf --- tests/test-replication.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test-replication.c b/tests/test-replication.c index c8165ae954..f085d1993a 100644 --- a/tests/test-replication.c +++ b/tests/test-replication.c @@ -207,13 +207,17 @@ static BlockBackend *start_primary(void) static void teardown_primary(void) { BlockBackend *blk; + AioContext *ctx; =20 /* remove P_ID */ blk =3D blk_by_name(P_ID); assert(blk); =20 + ctx =3D blk_get_aio_context(blk); + aio_context_acquire(ctx); monitor_remove_blk(blk); blk_unref(blk); + aio_context_release(ctx); } =20 static void test_primary_read(void) @@ -365,20 +369,27 @@ static void teardown_secondary(void) { /* only need to destroy two BBs */ BlockBackend *blk; + AioContext *ctx; =20 /* remove S_LOCAL_DISK_ID */ blk =3D blk_by_name(S_LOCAL_DISK_ID); assert(blk); =20 + ctx =3D blk_get_aio_context(blk); + aio_context_acquire(ctx); monitor_remove_blk(blk); blk_unref(blk); + aio_context_release(ctx); =20 /* remove S_ID */ blk =3D blk_by_name(S_ID); assert(blk); =20 + ctx =3D blk_get_aio_context(blk); + aio_context_acquire(ctx); monitor_remove_blk(blk); blk_unref(blk); + aio_context_release(ctx); } =20 static void test_secondary_read(void) --=20 2.13.6