thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-block-Lock-AioContext-for-drain_end-in-blockdev-reop.patch

0727d3
From b21fa5ecd9acf2b91839a2915fb4bb39dac4c803 Mon Sep 17 00:00:00 2001
0727d3
From: Kevin Wolf <kwolf@redhat.com>
0727d3
Date: Thu, 3 Feb 2022 15:05:33 +0100
0727d3
Subject: [PATCH 2/5] block: Lock AioContext for drain_end in blockdev-reopen
0727d3
0727d3
RH-Author: Kevin Wolf <kwolf@redhat.com>
0727d3
RH-MergeRequest: 142: block: Lock AioContext for drain_end in blockdev-reopen
0727d3
RH-Commit: [1/2] 98de3b5987f88ea6b4b503f623d6c4475574e037
0727d3
RH-Bugzilla: 2067118
0727d3
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
0727d3
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0727d3
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
0727d3
0727d3
bdrv_subtree_drained_end() requires the caller to hold the AioContext
0727d3
lock for the drained node. Not doing this for nodes outside of the main
0727d3
AioContext leads to crashes when AIO_WAIT_WHILE() needs to wait and
0727d3
tries to temporarily release the lock.
0727d3
0727d3
Fixes: 3908b7a8994fa5ef7a89aa58cd5a02fc58141592
0727d3
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2046659
0727d3
Reported-by: Qing Wang <qinwang@redhat.com>
0727d3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0727d3
Message-Id: <20220203140534.36522-2-kwolf@redhat.com>
0727d3
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
0727d3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0727d3
(cherry picked from commit aba8205be0707b9d108e32254e186ba88107a869)
0727d3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0727d3
---
0727d3
 blockdev.c | 11 ++++++++++-
0727d3
 1 file changed, 10 insertions(+), 1 deletion(-)
0727d3
0727d3
diff --git a/blockdev.c b/blockdev.c
0727d3
index b35072644e..565f6a81fd 100644
0727d3
--- a/blockdev.c
0727d3
+++ b/blockdev.c
0727d3
@@ -3562,6 +3562,7 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
0727d3
 {
0727d3
     BlockReopenQueue *queue = NULL;
0727d3
     GSList *drained = NULL;
0727d3
+    GSList *p;
0727d3
 
0727d3
     /* Add each one of the BDS that we want to reopen to the queue */
0727d3
     for (; reopen_list != NULL; reopen_list = reopen_list->next) {
0727d3
@@ -3611,7 +3612,15 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
0727d3
 
0727d3
 fail:
0727d3
     bdrv_reopen_queue_free(queue);
0727d3
-    g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end);
0727d3
+    for (p = drained; p; p = p->next) {
0727d3
+        BlockDriverState *bs = p->data;
0727d3
+        AioContext *ctx = bdrv_get_aio_context(bs);
0727d3
+
0727d3
+        aio_context_acquire(ctx);
0727d3
+        bdrv_subtree_drained_end(bs);
0727d3
+        aio_context_release(ctx);
0727d3
+    }
0727d3
+    g_slist_free(drained);
0727d3
 }
0727d3
 
0727d3
 void qmp_blockdev_del(const char *node_name, Error **errp)
0727d3
-- 
0727d3
2.27.0
0727d3