mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
block: Protect bs->file with graph_lock
Almost all functions that access bs->file already take the graph lock now. Add locking to the remaining users and finally annotate the struct field itself as protected by the graph lock. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-25-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
a4b740db5e
commit
1f051dcbdf
15 changed files with 97 additions and 41 deletions
12
block/qed.c
12
block/qed.c
|
@ -612,7 +612,7 @@ static int bdrv_qed_reopen_prepare(BDRVReopenState *state,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void bdrv_qed_close(BlockDriverState *bs)
|
||||
static void GRAPH_RDLOCK bdrv_qed_do_close(BlockDriverState *bs)
|
||||
{
|
||||
BDRVQEDState *s = bs->opaque;
|
||||
|
||||
|
@ -631,6 +631,14 @@ static void bdrv_qed_close(BlockDriverState *bs)
|
|||
qemu_vfree(s->l1_table);
|
||||
}
|
||||
|
||||
static void GRAPH_UNLOCKED bdrv_qed_close(BlockDriverState *bs)
|
||||
{
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
|
||||
bdrv_qed_do_close(bs);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_UNLOCKED
|
||||
bdrv_qed_co_create(BlockdevCreateOptions *opts, Error **errp)
|
||||
{
|
||||
|
@ -1574,7 +1582,7 @@ bdrv_qed_co_invalidate_cache(BlockDriverState *bs, Error **errp)
|
|||
BDRVQEDState *s = bs->opaque;
|
||||
int ret;
|
||||
|
||||
bdrv_qed_close(bs);
|
||||
bdrv_qed_do_close(bs);
|
||||
|
||||
bdrv_qed_init_state(bs);
|
||||
qemu_co_mutex_lock(&s->table_lock);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue