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