Blame SOURCES/kvm-block-Expect-graph-changes-in-bdrv_parent_drained_be.patch

4a2fec
From 2a9bf55a3db6b1a4a20c07fa030fde5ded02cf92 Mon Sep 17 00:00:00 2001
4a2fec
From: Jeffrey Cody <jcody@redhat.com>
4a2fec
Date: Thu, 30 Nov 2017 22:49:12 +0100
4a2fec
Subject: [PATCH 08/21] block: Expect graph changes in
4a2fec
 bdrv_parent_drained_begin/end
4a2fec
4a2fec
RH-Author: Jeffrey Cody <jcody@redhat.com>
4a2fec
Message-id: <09d305a1846240448bc742a53a49ea87950e427d.1511985875.git.jcody@redhat.com>
4a2fec
Patchwork-id: 78047
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 08/11] block: Expect graph changes in bdrv_parent_drained_begin/end
4a2fec
Bugzilla: 1506531
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
4a2fec
From: Kevin Wolf <kwolf@redhat.com>
4a2fec
4a2fec
The .drained_begin/end callbacks can (directly or indirectly via
4a2fec
aio_poll()) cause block nodes to be removed or the current BdrvChild to
4a2fec
point to a different child node.
4a2fec
4a2fec
Use QLIST_FOREACH_SAFE() to make sure we don't access invalid
4a2fec
BlockDriverStates or accidentally continue iterating the parents of the
4a2fec
new child node instead of the node we actually came from.
4a2fec
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
Tested-by: Jeff Cody <jcody@redhat.com>
4a2fec
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Reviewed-by: Jeff Cody <jcody@redhat.com>
4a2fec
Reviewed-by: Alberto Garcia <berto@igalia.com>
4a2fec
Reviewed-by: Fam Zheng <famz@redhat.com>
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
(cherry picked from commit 02d213009d571bcd7171e3ff9234722a11d30d1b)
4a2fec
Signed-off-by: Jeff Cody <jcody@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 block/io.c | 8 ++++----
4a2fec
 1 file changed, 4 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/block/io.c b/block/io.c
4a2fec
index 3a717bc..4ff2f25 100644
4a2fec
--- a/block/io.c
4a2fec
+++ b/block/io.c
4a2fec
@@ -39,9 +39,9 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
4a2fec
 
4a2fec
 void bdrv_parent_drained_begin(BlockDriverState *bs)
4a2fec
 {
4a2fec
-    BdrvChild *c;
4a2fec
+    BdrvChild *c, *next;
4a2fec
 
4a2fec
-    QLIST_FOREACH(c, &bs->parents, next_parent) {
4a2fec
+    QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
4a2fec
         if (c->role->drained_begin) {
4a2fec
             c->role->drained_begin(c);
4a2fec
         }
4a2fec
@@ -50,9 +50,9 @@ void bdrv_parent_drained_begin(BlockDriverState *bs)
4a2fec
 
4a2fec
 void bdrv_parent_drained_end(BlockDriverState *bs)
4a2fec
 {
4a2fec
-    BdrvChild *c;
4a2fec
+    BdrvChild *c, *next;
4a2fec
 
4a2fec
-    QLIST_FOREACH(c, &bs->parents, next_parent) {
4a2fec
+    QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
4a2fec
         if (c->role->drained_end) {
4a2fec
             c->role->drained_end(c);
4a2fec
         }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec