From patchwork Wed Oct 28 10:46:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 537286 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 BA29C1402B8 for ; Wed, 28 Oct 2015 21:47:26 +1100 (AEDT) Received: from localhost ([::1]:36692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrOGK-0001tQ-E6 for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2015 06:47:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrOG2-0001ZT-NF for qemu-devel@nongnu.org; Wed, 28 Oct 2015 06:47:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrOG1-0001sD-SK for qemu-devel@nongnu.org; Wed, 28 Oct 2015 06:47:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrOFv-0001ru-4X; Wed, 28 Oct 2015 06:46:59 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B4E5A91E8F; Wed, 28 Oct 2015 10:46:58 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9SAkubp028652; Wed, 28 Oct 2015 06:46:57 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 28 Oct 2015 11:46:51 +0100 Message-Id: <1446029211-27148-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com Subject: [Qemu-devel] [PATCH] block: Consider all child nodes in bdrv_requests_pending() 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 function manually recursed into bs->file and bs->backing to check whether there were any requests pending, but it ignored other children. There's no need to special case file and backing here, so just replace these two explicit recursions by a loop recursing for all child nodes. Reported-by: Max Reitz Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Reviewed-by: Jeff Cody --- block/io.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index 5ac6256..8dcad3b 100644 --- a/block/io.c +++ b/block/io.c @@ -216,6 +216,8 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs) /* Check if any requests are in-flight (including throttled requests) */ bool bdrv_requests_pending(BlockDriverState *bs) { + BdrvChild *child; + if (!QLIST_EMPTY(&bs->tracked_requests)) { return true; } @@ -225,12 +227,13 @@ bool bdrv_requests_pending(BlockDriverState *bs) if (!qemu_co_queue_empty(&bs->throttled_reqs[1])) { return true; } - if (bs->file && bdrv_requests_pending(bs->file->bs)) { - return true; - } - if (bs->backing && bdrv_requests_pending(bs->backing->bs)) { - return true; + + QLIST_FOREACH(child, &bs->children, next) { + if (bdrv_requests_pending(child->bs)) { + return true; + } } + return false; }