From patchwork Mon Apr 27 15:53:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 465107 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 46F50140318 for ; Tue, 28 Apr 2015 01:54:38 +1000 (AEST) Received: from localhost ([::1]:56034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmlMi-00057q-Fl for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2015 11:54:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmlLa-0003dg-Po for qemu-devel@nongnu.org; Mon, 27 Apr 2015 11:53:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmlLW-0000gY-Ss for qemu-devel@nongnu.org; Mon, 27 Apr 2015 11:53:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmlLQ-0000Tl-9o; Mon, 27 Apr 2015 11:53:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C6B948E769; Mon, 27 Apr 2015 15:53:15 +0000 (UTC) Received: from localhost (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3RFrEoI027188; Mon, 27 Apr 2015 11:53:15 -0400 From: Stefan Hajnoczi To: Date: Mon, 27 Apr 2015 16:53:10 +0100 Message-Id: <1430149991-29850-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1430149991-29850-1-git-send-email-stefanha@redhat.com> References: <1430149991-29850-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH v3 1/2] block: replace bdrv_states iteration with bdrv_next() 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 The bdrv_states list is a static variable in block.c. bdrv_drain_all() and bdrv_flush_all() use this variable to iterate over all drives. The next patch will move bdrv_drain_all() and bdrv_flush_all() out of block.c so it's necessary to switch to the public bdrv_next() interface. Signed-off-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia --- block.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index ec23594..1f0a4e2 100644 --- a/block.c +++ b/block.c @@ -2051,9 +2051,9 @@ void bdrv_drain_all(void) { /* Always run first iteration so any pending completion BHs run */ bool busy = true; - BlockDriverState *bs; + BlockDriverState *bs = NULL; - QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); @@ -2065,8 +2065,9 @@ void bdrv_drain_all(void) while (busy) { busy = false; + bs = NULL; - QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); @@ -2075,7 +2076,8 @@ void bdrv_drain_all(void) } } - QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + bs = NULL; + while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); @@ -4015,10 +4017,10 @@ int bdrv_get_flags(BlockDriverState *bs) int bdrv_flush_all(void) { - BlockDriverState *bs; + BlockDriverState *bs = NULL; int result = 0; - QTAILQ_FOREACH(bs, &bdrv_states, device_list) { + while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); int ret;