aboutsummaryrefslogtreecommitdiff
path: root/block/replication.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-10-27 17:53:33 +0200
committerKevin Wolf <kwolf@redhat.com>2023-11-08 17:56:18 +0100
commit1f051dcbdf2e4b6f518db731c84e304b2b9d15ce (patch)
treec96479cc14a8cc90443bc4f7fe46afbfa76a4006 /block/replication.c
parenta4b740db5ee3db0d5b76a6ea9895875763453187 (diff)
downloadqemu-1f051dcbdf2e4b6f518db731c84e304b2b9d15ce.zip
qemu-1f051dcbdf2e4b6f518db731c84e304b2b9d15ce.tar.gz
qemu-1f051dcbdf2e4b6f518db731c84e304b2b9d15ce.tar.bz2
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>
Diffstat (limited to 'block/replication.c')
-rw-r--r--block/replication.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/block/replication.c b/block/replication.c
index 49ecc60..43e2594 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -311,7 +311,7 @@ static void GRAPH_UNLOCKED
secondary_do_checkpoint(BlockDriverState *bs, Error **errp)
{
BDRVReplicationState *s = bs->opaque;
- BdrvChild *active_disk = bs->file;
+ BdrvChild *active_disk;
Error *local_err = NULL;
int ret;
@@ -328,6 +328,7 @@ secondary_do_checkpoint(BlockDriverState *bs, Error **errp)
return;
}
+ active_disk = bs->file;
if (!active_disk->bs->drv) {
error_setg(errp, "Active disk %s is ejected",
active_disk->bs->node_name);
@@ -755,11 +756,13 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp)
return;
}
+ bdrv_graph_rdlock_main_loop();
s->stage = BLOCK_REPLICATION_FAILOVER;
s->commit_job = commit_active_start(
NULL, bs->file->bs, s->secondary_disk->bs,
JOB_INTERNAL, 0, BLOCKDEV_ON_ERROR_REPORT,
NULL, replication_done, bs, true, errp);
+ bdrv_graph_rdunlock_main_loop();
break;
default:
aio_context_release(aio_context);