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

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