block: Fix AioContext locking in bdrv_open_backing_file()
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> Message-ID: <20230605085711.21261-9-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
f665f01f72
commit
8aa0454219
5
block.c
5
block.c
|
@ -3526,6 +3526,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
bool implicit_backing = false;
|
bool implicit_backing = false;
|
||||||
BlockDriverState *backing_hd;
|
BlockDriverState *backing_hd;
|
||||||
|
AioContext *backing_hd_ctx;
|
||||||
QDict *options;
|
QDict *options;
|
||||||
QDict *tmp_parent_options = NULL;
|
QDict *tmp_parent_options = NULL;
|
||||||
Error *local_err = 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
|
/* Hook up the backing file link; drop our reference, bs owns the
|
||||||
* backing_hd reference now */
|
* 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);
|
ret = bdrv_set_backing_hd(bs, backing_hd, errp);
|
||||||
bdrv_unref(backing_hd);
|
bdrv_unref(backing_hd);
|
||||||
|
aio_context_release(backing_hd_ctx);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto free_exit;
|
goto free_exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue