From patchwork Tue Sep 19 15:50:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 815627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxS5x4strz9sPm for ; Wed, 20 Sep 2017 01:51:17 +1000 (AEST) Received: from localhost ([::1]:43702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duKnr-0006nP-Ol for incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 11:51:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duKnF-0006lz-Uq for qemu-devel@nongnu.org; Tue, 19 Sep 2017 11:50:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duKnF-00053n-3w for qemu-devel@nongnu.org; Tue, 19 Sep 2017 11:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43862) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duKn7-0004wZ-T0; Tue, 19 Sep 2017 11:50:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A929F3A260; Tue, 19 Sep 2017 15:50:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A929F3A260 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com Received: from localhost (ovpn-117-87.ams2.redhat.com [10.36.117.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4937F5D6A4; Tue, 19 Sep 2017 15:50:26 +0000 (UTC) From: Stefan Hajnoczi To: Date: Tue, 19 Sep 2017 16:50:25 +0100 Message-Id: <20170919155025.4098-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 19 Sep 2017 15:50:28 +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] [PATCH] throttle-groups: update tg->any_timer_armed[] on detach 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Manos Pitsidianakis , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Clear tg->any_timer_armed[] when throttling timers are destroy during AioContext attach/detach. Failure to do so causes throttling to hang because we believe the timer is already scheduled! The following was broken at least since QEMU 2.10.0 with -drive iops=100: $ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 (qemu) stop (qemu) cont ...I/O is stuck... Reported-by: Yongxue Hong Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- block/throttle-groups.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 6ba992c8d7..2bfd03faa0 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -592,7 +592,20 @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm, void throttle_group_detach_aio_context(ThrottleGroupMember *tgm) { ThrottleTimers *tt = &tgm->throttle_timers; + ThrottleGroup *tg = container_of(tgm->throttle_state, ThrottleGroup, ts); + throttle_timers_detach_aio_context(tt); + + /* Forget about these timers, they have been destroyed */ + qemu_mutex_lock(&tg->lock); + if (tg->tokens[0] == tgm) { + tg->any_timer_armed[0] = false; + } + if (tg->tokens[1] == tgm) { + tg->any_timer_armed[1] = false; + } + qemu_mutex_unlock(&tg->lock); + tgm->aio_context = NULL; }