From patchwork Tue Apr 28 15:00:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 465623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 25A9214016A for ; Wed, 29 Apr 2015 01:12:05 +1000 (AEST) Received: from localhost ([::1]:34102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn7B5-0000qy-6O for incoming@patchwork.ozlabs.org; Tue, 28 Apr 2015 11:12:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn71Q-0008RK-5g for qemu-devel@nongnu.org; Tue, 28 Apr 2015 11:02:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn71M-00021I-1m for qemu-devel@nongnu.org; Tue, 28 Apr 2015 11:02:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn71A-0001x9-Rh; Tue, 28 Apr 2015 11:01:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3SF1lVB031722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 28 Apr 2015 11:01:48 -0400 Received: from noname.redhat.com (ovpn-116-103.ams2.redhat.com [10.36.116.103]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3SF1194021485; Tue, 28 Apr 2015 11:01:46 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 28 Apr 2015 17:00:09 +0200 Message-Id: <1430233258-31807-28-git-send-email-kwolf@redhat.com> In-Reply-To: <1430233258-31807-1-git-send-email-kwolf@redhat.com> References: <1430233258-31807-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 27/76] block: Pause block jobs in bdrv_drain_all X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Fam Zheng This is necessary to suppress more IO requests from being generated from block job coroutines. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Reviewed-by: Paolo Bonzini Reviewed-by: Alberto Garcia Message-id: 1428069921-2957-3-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/block.c b/block.c index 670d7e4..70aed80 100644 --- a/block.c +++ b/block.c @@ -2040,6 +2040,16 @@ void bdrv_drain_all(void) bool busy = true; BlockDriverState *bs; + QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + AioContext *aio_context = bdrv_get_aio_context(bs); + + aio_context_acquire(aio_context); + if (bs->job) { + block_job_pause(bs->job); + } + aio_context_release(aio_context); + } + while (busy) { busy = false; @@ -2051,6 +2061,16 @@ void bdrv_drain_all(void) aio_context_release(aio_context); } } + + QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + AioContext *aio_context = bdrv_get_aio_context(bs); + + aio_context_acquire(aio_context); + if (bs->job) { + block_job_resume(bs->job); + } + aio_context_release(aio_context); + } } /* make a BlockDriverState anonymous by removing from bdrv_state and