From patchwork Fri Sep 7 16:15:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 10592333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAC5A13BB for ; Fri, 7 Sep 2018 16:21:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC4942B9B4 for ; Fri, 7 Sep 2018 16:21:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0A1F2B9CD; Fri, 7 Sep 2018 16:21:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 74EFE2B9B4 for ; Fri, 7 Sep 2018 16:21:07 +0000 (UTC) Received: from localhost ([::1]:39472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyJVK-0002Td-Kx for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Sep 2018 12:21:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyJQU-0006AD-JU for qemu-devel@nongnu.org; Fri, 07 Sep 2018 12:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fyJQS-000410-2i for qemu-devel@nongnu.org; Fri, 07 Sep 2018 12:16:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50646 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fyJQ8-0003Hk-90; Fri, 07 Sep 2018 12:15:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EC87C12A7; Fri, 7 Sep 2018 16:15:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-56.ams2.redhat.com [10.36.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC8052166BA3; Fri, 7 Sep 2018 16:15:32 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 7 Sep 2018 18:15:06 +0200 Message-Id: <20180907161520.26349-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 07 Sep 2018 16:15:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 07 Sep 2018 16:15:38 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 00/14] Fix some jobs/drain/aio_poll related hangs 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, famz@redhat.com, slp@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Especially the combination of iothreads, block jobs and drain tends to lead to hangs currently. This series fixes a few of these bugs, although there are more of them, to be addressed in separate patches. The primary goal of this series is to fix the scenario from: https://bugzilla.redhat.com/show_bug.cgi?id=1601212 A simplified reproducer of the reported problem looks like this (two concurrent commit block jobs for disks in an iothread): $qemu -qmp stdio \ -object iothread,id=iothread1 \ -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=0x6,iothread=iothread1 \ -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=hd0 \ -device scsi-hd,drive=drive_image1,id=image1,bootindex=1 \ -drive id=drive_image2,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=hd1 \ -device scsi-hd,drive=drive_image2,id=image2,bootindex=2 {"execute":"qmp_capabilities"} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image1","snapshot-file":"sn1"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image1","snapshot-file":"sn11"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image1","snapshot-file":"sn111"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image2","snapshot-file":"sn2"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image2","snapshot-file":"sn22"}} {"execute":"blockdev-snapshot-sync","arguments":{"device":"drive_image2","snapshot-file":"sn222"}} { "execute": "block-commit", "arguments": { "device": "drive_image2","base":"sn2","backing-file":"sn2","top":"sn22"}} { "execute": "block-commit", "arguments": { "device": "drive_image1","base":"sn1","backing-file":"sn1","top":"sn11"}} {"execute":"quit"} Kevin Wolf (14): blockjob: Wake up BDS when job becomes idle test-bdrv-drain: Drain with block jobs in an I/O thread test-blockjob: Acquire AioContext around job_finish_sync() job: Use AIO_WAIT_WHILE() in job_finish_sync() test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback block: Add missing locking in bdrv_co_drain_bh_cb() aio-wait: Increase num_waiters even in home thread block-backend: Add .drained_poll callback block-backend: Fix potential double blk_delete() block-backend: Decrease in_flight only after callback mirror: Fix potential use-after-free in active commit blockjob: Lie better in child_job_drained_poll() block: Remove aio_poll() in bdrv_drain_poll variants test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level() include/block/aio-wait.h | 2 + include/block/blockjob.h | 13 ++++++ include/qemu/coroutine.h | 5 +++ include/qemu/job.h | 12 ++++++ block/block-backend.c | 26 ++++++++++- block/io.c | 23 ++++++---- block/mirror.c | 9 ++++ blockjob.c | 20 ++++++++- job.c | 29 +++++++++---- tests/test-bdrv-drain.c | 110 ++++++++++++++++++++++++++++++++++++++++++++--- tests/test-blockjob.c | 6 +++ util/qemu-coroutine.c | 5 +++ 12 files changed, 235 insertions(+), 25 deletions(-)