From patchwork Mon Apr 4 13:43:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 8741211 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3EB25C0553 for ; Mon, 4 Apr 2016 13:51:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F5FD2025A for ; Mon, 4 Apr 2016 13:51:24 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 69D7C2024F for ; Mon, 4 Apr 2016 13:51:23 +0000 (UTC) Received: from localhost ([::1]:58795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an4uY-0003vz-Qd for patchwork-qemu-devel@patchwork.kernel.org; Mon, 04 Apr 2016 09:51:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an4op-0002Du-8L for qemu-devel@nongnu.org; Mon, 04 Apr 2016 09:45:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1an4on-0000Ev-LN for qemu-devel@nongnu.org; Mon, 04 Apr 2016 09:45:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:44387 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an4on-0008Rz-Ex; Mon, 04 Apr 2016 09:45:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CSAwCybgJX/5tjdVtdgzeBUKcVAQEBAQEFAYERAZBmgg8BDYFyhg0CgTM4FAEBAQEBAQFlJ4RCAQEEJ1IQPxI8GxmIKwG9BwEBCCCFWIJFh1iFCgWOPYlEjgiJOoVVRI5WHgEBQoIEGYFNaYgmAQEB X-IPAS-Result: A2CSAwCybgJX/5tjdVtdgzeBUKcVAQEBAQEFAYERAZBmgg8BDYFyhg0CgTM4FAEBAQEBAQFlJ4RCAQEEJ1IQPxI8GxmIKwG9BwEBCCCFWIJFh1iFCgWOPYlEjgiJOoVVRI5WHgEBQoIEGYFNaYgmAQEB X-IronPort-AV: E=Sophos;i="5.24,440,1454972400"; d="scan'208";a="39334336" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 04 Apr 2016 15:44:37 +0200 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1an4o1-00050z-0I; Mon, 04 Apr 2016 15:44:37 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1an4ni-0003vI-Vs; Mon, 04 Apr 2016 16:44:18 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 4 Apr 2016 16:43:52 +0300 Message-Id: X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v9 02/11] block: use the block job list 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP bdrv_drain_all() pauses all block jobs by using bdrv_next() to iterate over all top-level BlockDriverStates. Therefore the code is unable to find block jobs in other nodes. This patch uses block_job_next() to iterate over all block jobs. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block/io.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/block/io.c b/block/io.c index c4869b9..884ed1e 100644 --- a/block/io.c +++ b/block/io.c @@ -288,15 +288,21 @@ void bdrv_drain_all(void) /* Always run first iteration so any pending completion BHs run */ bool busy = true; BlockDriverState *bs = NULL; + BlockJob *job = NULL; GSList *aio_ctxs = NULL, *ctx; + while ((job = block_job_next(job))) { + AioContext *aio_context = bdrv_get_aio_context(job->bs); + + aio_context_acquire(aio_context); + block_job_pause(job); + aio_context_release(aio_context); + } + while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - if (bs->job) { - block_job_pause(bs->job); - } bdrv_drain_recurse(bs); aio_context_release(aio_context); @@ -333,14 +339,11 @@ void bdrv_drain_all(void) } } - bs = NULL; - while ((bs = bdrv_next(bs))) { - AioContext *aio_context = bdrv_get_aio_context(bs); + while ((job = block_job_next(job))) { + AioContext *aio_context = bdrv_get_aio_context(job->bs); aio_context_acquire(aio_context); - if (bs->job) { - block_job_resume(bs->job); - } + block_job_resume(job); aio_context_release(aio_context); } g_slist_free(aio_ctxs);