Skip to contentSkip to conversation

block: Consider all child nodes in bdrv_requests_pending()

PATCH Applied Kevin Wolf 4 participants 4 messages Oct 28, 2015 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 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.

---
 block/io.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
block/io.c +8 -5
index 5ac6256..8dcad3b 100644
@@ -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;
 }
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · 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.

Berto

Reviewed-by on v1 1/1
#2 lore raw
In reply to Kevin Wolf
Quoted 48 lines · 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.

---
 block/io.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
block/io.c +8 -5
index 5ac6256..8dcad3b 100644
@@ -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;
 }
 
Signature · 1 line
1.8.3.1
#3 lore raw
In reply to Kevin Wolf
Quoted 11 lines · 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.

---
 block/io.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan