[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/11] block: Fix AioContext locking in bdrv_open_backing_file()
From: |
Kevin Wolf |
Subject: |
[PATCH 08/11] block: Fix AioContext locking in bdrv_open_backing_file() |
Date: |
Wed, 31 May 2023 13:02:28 +0200 |
bdrv_set_backing() requires the caller to hold the AioContext lock for
@backing_hd. Take it in bdrv_open_backing_file() before calling the
function.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block.c b/block.c
index 954b9923d9..d5f8231f31 100644
--- a/block.c
+++ b/block.c
@@ -3526,6 +3526,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*parent_options,
int ret = 0;
bool implicit_backing = false;
BlockDriverState *backing_hd;
+ AioContext *backing_hd_ctx;
QDict *options;
QDict *tmp_parent_options = NULL;
Error *local_err = NULL;
@@ -3610,8 +3611,12 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*parent_options,
/* Hook up the backing file link; drop our reference, bs owns the
* backing_hd reference now */
+ backing_hd_ctx = bdrv_get_aio_context(backing_hd);
+ aio_context_acquire(backing_hd_ctx);
ret = bdrv_set_backing_hd(bs, backing_hd, errp);
bdrv_unref(backing_hd);
+ aio_context_release(backing_hd_ctx);
+
if (ret < 0) {
goto free_exit;
}
--
2.40.1
- [PATCH 00/11] block: Re-enable the graph lock, Kevin Wolf, 2023/05/31
- [PATCH 09/11] blockjob: Fix AioContext locking in block_job_add_bdrv(), Kevin Wolf, 2023/05/31
- [PATCH 02/11] qdev-properties-system: Lock AioContext for blk_insert_bs(), Kevin Wolf, 2023/05/31
- [PATCH 03/11] test-block-iothread: Lock AioContext for blk_insert_bs(), Kevin Wolf, 2023/05/31
- [PATCH 05/11] block: Fix AioContext locking in bdrv_attach_child_common(), Kevin Wolf, 2023/05/31
- [PATCH 10/11] graph-lock: Unlock the AioContext while polling, Kevin Wolf, 2023/05/31
- [PATCH 01/11] iotests: Test active commit with iothread and background I/O, Kevin Wolf, 2023/05/31
- [PATCH 06/11] block: Fix AioContext locking in bdrv_reopen_parse_file_or_backing(), Kevin Wolf, 2023/05/31
- [PATCH 11/11] Revert "graph-lock: Disable locking for now", Kevin Wolf, 2023/05/31
- [PATCH 08/11] block: Fix AioContext locking in bdrv_open_backing_file(),
Kevin Wolf <=
- [PATCH 04/11] block: Fix AioContext locking in bdrv_open_child(), Kevin Wolf, 2023/05/31
- [PATCH 07/11] block: Fix AioContext locking in bdrv_open_inherit(), Kevin Wolf, 2023/05/31