aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorEmanuele Giuseppe Esposito <eesposit@redhat.com>2022-09-26 05:32:06 -0400
committerKevin Wolf <kwolf@redhat.com>2022-10-07 12:11:41 +0200
commit3ed4f708fe12537066d21f3dd111af013f7a6b8c (patch)
tree356bc8ca58f2ba05692c3a7c117f95a91661d8a8 /block
parentef02dac28e2ae7ac1d527dd715b459288bc652a5 (diff)
downloadqemu-3ed4f708fe12537066d21f3dd111af013f7a6b8c.zip
qemu-3ed4f708fe12537066d21f3dd111af013f7a6b8c.tar.gz
qemu-3ed4f708fe12537066d21f3dd111af013f7a6b8c.tar.bz2
jobs: protect job.aio_context with BQL and job_mutex
In order to make it thread safe, implement a "fake rwlock", where we allow reads under BQL *or* job_mutex held, but writes only under BQL *and* job_mutex. The only write we have is in child_job_set_aio_ctx, which always happens under drain (so the job is paused). For this reason, introduce job_set_aio_context and make sure that the context is set under BQL, job_mutex and drain. Also make sure all other places where the aiocontext is read are protected. The reads in commit.c and mirror.c are actually safe, because always done under BQL. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Message-Id: <20220926093214.506243-14-eesposit@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/replication.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/block/replication.c b/block/replication.c
index 55c8f89..5977f7a 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -142,6 +142,7 @@ static void replication_close(BlockDriverState *bs)
{
BDRVReplicationState *s = bs->opaque;
Job *commit_job;
+ GLOBAL_STATE_CODE();
if (s->stage == BLOCK_REPLICATION_RUNNING) {
replication_stop(s->rs, false, NULL);