OSDN Git Service

stream: Fix AioContext locking during bdrv_graph_wrlock()
authorKevin Wolf <kwolf@redhat.com>
Wed, 15 Nov 2023 17:20:11 +0000 (18:20 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 21 Nov 2023 11:45:21 +0000 (12:45 +0100)
commit1dbc7d344246e1c8000825bee220e4c2767ba765
tree69ad6b8858b175da248e766ec38d38a33a9c58b5
parent6bc0bcc89f847839cf3d459a55290dda8801d9d3
stream: Fix AioContext locking during bdrv_graph_wrlock()

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>
block/stream.c