ae23c9
From 92a9a816dd93a361ad2e0751e503c5e12accf38b Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Wed, 10 Oct 2018 20:22:03 +0100
ae23c9
Subject: [PATCH 37/49] block-backend: Add .drained_poll callback
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20181010202213.7372-25-kwolf@redhat.com>
ae23c9
Patchwork-id: 82614
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH 34/44] block-backend: Add .drained_poll callback
ae23c9
Bugzilla: 1637976
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Thomas Huth <thuth@redhat.com>
ae23c9
ae23c9
A bdrv_drain operation must ensure that all parents are quiesced, this
ae23c9
includes BlockBackends. Otherwise, callbacks called by requests that are
ae23c9
completed on the BDS layer, but not quite yet on the BlockBackend layer
ae23c9
could still create new requests.
ae23c9
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Reviewed-by: Fam Zheng <famz@redhat.com>
ae23c9
Reviewed-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit fe5258a503a87e69be37c9ac48799e293809386e)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 block/block-backend.c | 9 +++++++++
ae23c9
 1 file changed, 9 insertions(+)
ae23c9
ae23c9
diff --git a/block/block-backend.c b/block/block-backend.c
ae23c9
index 3554b7e..dffc6f0 100644
ae23c9
--- a/block/block-backend.c
ae23c9
+++ b/block/block-backend.c
ae23c9
@@ -121,6 +121,7 @@ static void blk_root_inherit_options(int *child_flags, QDict *child_options,
ae23c9
     abort();
ae23c9
 }
ae23c9
 static void blk_root_drained_begin(BdrvChild *child);
ae23c9
+static bool blk_root_drained_poll(BdrvChild *child);
ae23c9
 static void blk_root_drained_end(BdrvChild *child);
ae23c9
 
ae23c9
 static void blk_root_change_media(BdrvChild *child, bool load);
ae23c9
@@ -294,6 +295,7 @@ static const BdrvChildRole child_root = {
ae23c9
     .get_parent_desc    = blk_root_get_parent_desc,
ae23c9
 
ae23c9
     .drained_begin      = blk_root_drained_begin,
ae23c9
+    .drained_poll       = blk_root_drained_poll,
ae23c9
     .drained_end        = blk_root_drained_end,
ae23c9
 
ae23c9
     .activate           = blk_root_activate,
ae23c9
@@ -2198,6 +2200,13 @@ static void blk_root_drained_begin(BdrvChild *child)
ae23c9
     }
ae23c9
 }
ae23c9
 
ae23c9
+static bool blk_root_drained_poll(BdrvChild *child)
ae23c9
+{
ae23c9
+    BlockBackend *blk = child->opaque;
ae23c9
+    assert(blk->quiesce_counter);
ae23c9
+    return !!blk->in_flight;
ae23c9
+}
ae23c9
+
ae23c9
 static void blk_root_drained_end(BdrvChild *child)
ae23c9
 {
ae23c9
     BlockBackend *blk = child->opaque;
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9