[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/12] block: Take AioContext lock in bdrv_open_driver()
From: |
Kevin Wolf |
Subject: |
[PATCH 09/12] block: Take AioContext lock in bdrv_open_driver() |
Date: |
Thu, 25 May 2023 14:47:10 +0200 |
bdrv_refresh_total_sectors() and bdrv_refresh_limits() expect to be
called under the AioContext lock of the node. Take the lock.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block.c b/block.c
index be9ae364fb..e368a43761 100644
--- a/block.c
+++ b/block.c
@@ -1613,6 +1613,7 @@ static int no_coroutine_fn GRAPH_UNLOCKED
bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name,
QDict *options, int open_flags, Error **errp)
{
+ AioContext *ctx;
Error *local_err = NULL;
int i, ret;
GLOBAL_STATE_CODE();
@@ -1660,15 +1661,21 @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver
*drv, const char *node_name,
bs->supported_read_flags |= BDRV_REQ_REGISTERED_BUF;
bs->supported_write_flags |= BDRV_REQ_REGISTERED_BUF;
+ /* Get the context after .bdrv_open, it can change the context */
+ ctx = bdrv_get_aio_context(bs);
+ aio_context_acquire(ctx);
+
ret = bdrv_refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
+ aio_context_release(ctx);
return ret;
}
bdrv_graph_rdlock_main_loop();
bdrv_refresh_limits(bs, NULL, &local_err);
bdrv_graph_rdunlock_main_loop();
+ aio_context_release(ctx);
if (local_err) {
error_propagate(errp, local_err);
--
2.40.1
- Re: [PATCH 07/12] raw-format: Fix open with 'file' in iothread, (continued)
- [PATCH 12/12] iotests: Test blockdev-create in iothread, Kevin Wolf, 2023/05/25
- [PATCH 08/12] copy-before-write: Fix open with child in iothread, Kevin Wolf, 2023/05/25
- [PATCH 04/12] block-backend: Fix blk_new_open() for iothreads, Kevin Wolf, 2023/05/25
- [PATCH 02/12] block: Clarify locking rules for bdrv_open(_inherit)(), Kevin Wolf, 2023/05/25
- [PATCH 09/12] block: Take AioContext lock in bdrv_open_driver(),
Kevin Wolf <=
- [PATCH 06/12] qcow2: Fix open with 'file' in iothread, Kevin Wolf, 2023/05/25
- [PATCH 10/12] block: Fix AioContext locking in bdrv_insert_node(), Kevin Wolf, 2023/05/25
- [PATCH 11/12] iotests: Make verify_virtio_scsi_pci_or_ccw() public, Kevin Wolf, 2023/05/25