thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 1808e560396872173f787f8e338e9837a4c3d626 Mon Sep 17 00:00:00 2001
ed5979
From: Kevin Wolf <kwolf@redhat.com>
ed5979
Date: Fri, 18 Nov 2022 18:41:00 +0100
ed5979
Subject: [PATCH 18/31] block: Inline bdrv_drain_invoke()
ed5979
ed5979
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
ed5979
RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
ed5979
RH-Bugzilla: 2155112
ed5979
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
ed5979
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ed5979
RH-Commit: [6/16] 2c7473a36360eb43d94b967deb12308cb5ea0d3b (sgarzarella/qemu-kvm-c-9-s)
ed5979
ed5979
bdrv_drain_invoke() has now two entirely separate cases that share no
ed5979
code any more and are selected depending on a bool parameter. Each case
ed5979
has only one caller. Just inline the function.
ed5979
ed5979
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ed5979
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
ed5979
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ed5979
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
ed5979
Message-Id: <20221118174110.55183-6-kwolf@redhat.com>
ed5979
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ed5979
(cherry picked from commit c7bc05f78ab31fb02fc9635f60b9bd22efc8d121)
ed5979
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
ed5979
---
ed5979
 block/io.c | 23 ++++++-----------------
ed5979
 1 file changed, 6 insertions(+), 17 deletions(-)
ed5979
ed5979
diff --git a/block/io.c b/block/io.c
ed5979
index f4ca62b034..a25103be6f 100644
ed5979
--- a/block/io.c
ed5979
+++ b/block/io.c
ed5979
@@ -242,21 +242,6 @@ typedef struct {
ed5979
     bool ignore_bds_parents;
ed5979
 } BdrvCoDrainData;
ed5979
 
ed5979
-/* Recursively call BlockDriver.bdrv_drain_begin/end callbacks */
ed5979
-static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
ed5979
-{
ed5979
-    if (!bs->drv || (begin && !bs->drv->bdrv_drain_begin) ||
ed5979
-            (!begin && !bs->drv->bdrv_drain_end)) {
ed5979
-        return;
ed5979
-    }
ed5979
-
ed5979
-    if (begin) {
ed5979
-        bs->drv->bdrv_drain_begin(bs);
ed5979
-    } else {
ed5979
-        bs->drv->bdrv_drain_end(bs);
ed5979
-    }
ed5979
-}
ed5979
-
ed5979
 /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
ed5979
 bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
ed5979
                      BdrvChild *ignore_parent, bool ignore_bds_parents)
ed5979
@@ -390,7 +375,9 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
ed5979
     }
ed5979
 
ed5979
     bdrv_parent_drained_begin(bs, parent, ignore_bds_parents);
ed5979
-    bdrv_drain_invoke(bs, true);
ed5979
+    if (bs->drv && bs->drv->bdrv_drain_begin) {
ed5979
+        bs->drv->bdrv_drain_begin(bs);
ed5979
+    }
ed5979
 }
ed5979
 
ed5979
 static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
ed5979
@@ -461,7 +448,9 @@ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
ed5979
     assert(bs->quiesce_counter > 0);
ed5979
 
ed5979
     /* Re-enable things in child-to-parent order */
ed5979
-    bdrv_drain_invoke(bs, false);
ed5979
+    if (bs->drv && bs->drv->bdrv_drain_end) {
ed5979
+        bs->drv->bdrv_drain_end(bs);
ed5979
+    }
ed5979
     bdrv_parent_drained_end(bs, parent, ignore_bds_parents);
ed5979
 
ed5979
     old_quiesce_counter = qatomic_fetch_dec(&bs->quiesce_counter);
ed5979
-- 
ed5979
2.31.1
ed5979