[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/9] block: Fix bdrv_graph_wrlock() call in blk_remove_bs()
From: |
Kevin Wolf |
Subject: |
[PULL 2/9] block: Fix bdrv_graph_wrlock() call in blk_remove_bs() |
Date: |
Tue, 21 Nov 2023 12:52:55 +0100 |
While not all callers of blk_remove_bs() are correct in this respect,
the assumption in the function is that callers hold the AioContext lock
of the BlockBackend (this is required by the drain calls in it).
In order to avoid deadlock in the nested event loop, bdrv_graph_wrlock()
has then to be called with the root BlockDriverState as its parameter
instead of NULL, so that this AioContext lock is temporarily dropped.
Fixes: https://issues.redhat.com/browse/RHEL-1761
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231115172012.112727-2-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/block-backend.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 4053134781..f6f05ead28 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -882,6 +882,8 @@ BlockBackend *blk_by_public(BlockBackendPublic *public)
/*
* Disassociates the currently associated BlockDriverState from @blk.
+ *
+ * The caller must hold the AioContext lock for the BlockBackend.
*/
void blk_remove_bs(BlockBackend *blk)
{
@@ -916,7 +918,7 @@ void blk_remove_bs(BlockBackend *blk)
root = blk->root;
blk->root = NULL;
- bdrv_graph_wrlock(NULL);
+ bdrv_graph_wrlock(root->bs);
bdrv_root_unref_child(root);
bdrv_graph_wrunlock();
}
--
2.42.0
- [PULL 0/9] Block layer fixes for 8.2.0-rc1, Kevin Wolf, 2023/11/21
- [PULL 2/9] block: Fix bdrv_graph_wrlock() call in blk_remove_bs(),
Kevin Wolf <=
- [PULL 4/9] stream: Fix AioContext locking during bdrv_graph_wrlock(), Kevin Wolf, 2023/11/21
- [PULL 1/9] hw/ide/ahci: fix legacy software reset, Kevin Wolf, 2023/11/21
- [PULL 5/9] iotests: Test two stream jobs in a single iothread, Kevin Wolf, 2023/11/21
- [PULL 6/9] ide/ioport: move ide_portio_list[] and ide_portio_list2[] definitions to IDE core, Kevin Wolf, 2023/11/21
- [PULL 3/9] block: Fix deadlocks in bdrv_graph_wrunlock(), Kevin Wolf, 2023/11/21
- [PULL 7/9] ide/pci: introduce pci_ide_update_mode() function, Kevin Wolf, 2023/11/21
- [PULL 9/9] hw/ide/via: implement legacy/native mode switching, Kevin Wolf, 2023/11/21
- [PULL 8/9] ide/via: don't attempt to set default BAR addresses, Kevin Wolf, 2023/11/21
- Re: [PULL 0/9] Block layer fixes for 8.2.0-rc1, Stefan Hajnoczi, 2023/11/21