Blame SOURCES/kvm-block-backend-Add-.drained_poll-callback.patch

357786
From 79543d4ff66ab2c8f7050e5a5749ea11d1f0c2c0 Mon Sep 17 00:00:00 2001
357786
From: Kevin Wolf <kwolf@redhat.com>
357786
Date: Fri, 14 Sep 2018 10:55:32 +0200
357786
Subject: [PATCH 41/49] block-backend: Add .drained_poll callback
357786
357786
RH-Author: Kevin Wolf <kwolf@redhat.com>
357786
Message-id: <20180914105540.18077-35-kwolf@redhat.com>
357786
Patchwork-id: 82190
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 34/42] block-backend: Add .drained_poll callback
357786
Bugzilla: 1601212
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Fam Zheng <famz@redhat.com>
357786
357786
A bdrv_drain operation must ensure that all parents are quiesced, this
357786
includes BlockBackends. Otherwise, callbacks called by requests that are
357786
completed on the BDS layer, but not quite yet on the BlockBackend layer
357786
could still create new requests.
357786
357786
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
357786
Reviewed-by: Fam Zheng <famz@redhat.com>
357786
Reviewed-by: Max Reitz <mreitz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 block/block-backend.c | 9 +++++++++
357786
 1 file changed, 9 insertions(+)
357786
357786
diff --git a/block/block-backend.c b/block/block-backend.c
357786
index 2262506..ea85770 100644
357786
--- a/block/block-backend.c
357786
+++ b/block/block-backend.c
357786
@@ -121,6 +121,7 @@ static void blk_root_inherit_options(int *child_flags, QDict *child_options,
357786
     abort();
357786
 }
357786
 static void blk_root_drained_begin(BdrvChild *child);
357786
+static bool blk_root_drained_poll(BdrvChild *child);
357786
 static void blk_root_drained_end(BdrvChild *child);
357786
 
357786
 static void blk_root_change_media(BdrvChild *child, bool load);
357786
@@ -294,6 +295,7 @@ static const BdrvChildRole child_root = {
357786
     .get_parent_desc    = blk_root_get_parent_desc,
357786
 
357786
     .drained_begin      = blk_root_drained_begin,
357786
+    .drained_poll       = blk_root_drained_poll,
357786
     .drained_end        = blk_root_drained_end,
357786
 
357786
     .activate           = blk_root_activate,
357786
@@ -2217,6 +2219,13 @@ static void blk_root_drained_begin(BdrvChild *child)
357786
     }
357786
 }
357786
 
357786
+static bool blk_root_drained_poll(BdrvChild *child)
357786
+{
357786
+    BlockBackend *blk = child->opaque;
357786
+    assert(blk->quiesce_counter);
357786
+    return !!blk->in_flight;
357786
+}
357786
+
357786
 static void blk_root_drained_end(BdrvChild *child)
357786
 {
357786
     BlockBackend *blk = child->opaque;
357786
-- 
357786
1.8.3.1
357786