From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrreA-00078P-BX for qemu-devel@nongnu.org; Thu, 29 Oct 2015 14:09:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrre9-0002kS-0w for qemu-devel@nongnu.org; Thu, 29 Oct 2015 14:09:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrre8-0002kM-SD for qemu-devel@nongnu.org; Thu, 29 Oct 2015 14:09:56 -0400 From: Stefan Hajnoczi Date: Thu, 29 Oct 2015 18:09:25 +0000 Message-Id: <1446142165-24416-13-git-send-email-stefanha@redhat.com> In-Reply-To: <1446142165-24416-1-git-send-email-stefanha@redhat.com> References: <1446142165-24416-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 12/12] block: Consider all child nodes in bdrv_requests_pending() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi From: Kevin Wolf 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 Message-id: 1446029211-27148-1-git-send-email-kwolf@redhat.com Signed-off-by: Stefan Hajnoczi --- 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; } -- 2.4.3