From: Kevin Wolf Date: Wed, 28 Oct 2015 10:46:51 +0000 (+0100) Subject: block: Consider all child nodes in bdrv_requests_pending() X-Git-Tag: v2.5.0-rc0~38^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=37a639a7fbc5c6b065c80e7e2de78d22af735496;p=qemu-xen-unstable.git block: Consider all child nodes in bdrv_requests_pending() 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 --- diff --git a/block/io.c b/block/io.c index 5ac6256ad3..8dcad3b3fe 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; }