cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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