Skip to content

Commit

Permalink
stream: Fix AioContext locking during bdrv_graph_wrlock()
Browse files Browse the repository at this point in the history
In stream_prepare(), we need to temporarily drop the AioContext lock
that job_prepare_locked() took for us while calling the graph write lock
functions which can poll.

All block nodes related to this block job are in the same AioContext, so
we can pass any of them to bdrv_graph_wrlock()/ bdrv_graph_wrunlock().
Unfortunately, the one that we picked is base, which can be NULL - and
in this case the AioContext lock is not released and deadlocks can
occur.

Fix this by passing s->target_bs, which is never NULL.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231115172012.112727-4-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
kevmw committed Nov 21, 2023
1 parent 6bc0bcc commit 1dbc7d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ static int stream_prepare(Job *job)
}
}

bdrv_graph_wrlock(base);
bdrv_graph_wrlock(s->target_bs);
bdrv_set_backing_hd_drained(unfiltered_bs, base, &local_err);
bdrv_graph_wrunlock(base);
bdrv_graph_wrunlock(s->target_bs);

/*
* This call will do I/O, so the graph can change again from here on.
Expand Down

0 comments on commit 1dbc7d3

Please sign in to comment.