From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufUN-0002kh-Mn for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:56:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dufUM-0006L3-Sc for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:56:31 -0400 From: Stefan Hajnoczi Date: Wed, 20 Sep 2017 11:17:40 +0100 Message-Id: <20170920101740.12490-1-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v2] throttle-groups: update tg->any_timer_armed[] on detach List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Max Reitz , Kevin Wolf , qemu-block@nongnu.org, Manos Pitsidianakis , Alberto Garcia , Stefan Hajnoczi Clear tg->any_timer_armed[] when throttling timers are destroyed 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 --- v2: * Use timer_pending(tt->timers[i]) instead of token [Berto] * Fix s/destroy/destroyed/ typo [Eric] block/throttle-groups.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 6ba992c8d7..0a49f3c409 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -592,6 +592,17 @@ 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); + + qemu_mutex_lock(&tg->lock); + if (timer_pending(tt->timers[0])) { + tg->any_timer_armed[0] = false; + } + if (timer_pending(tt->timers[1])) { + tg->any_timer_armed[1] = false; + } + qemu_mutex_unlock(&tg->lock); + throttle_timers_detach_aio_context(tt); tgm->aio_context = NULL; } -- 2.13.5