Skip to content
Snippets Groups Projects
  • Kevin Wolf's avatar
    1dbc7d34
    stream: Fix AioContext locking during bdrv_graph_wrlock() · 1dbc7d34
    Kevin Wolf authored
    
    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: default avatarKevin Wolf <kwolf@redhat.com>
    Message-ID: <20231115172012.112727-4-kwolf@redhat.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    1dbc7d34
    History
    stream: Fix AioContext locking during bdrv_graph_wrlock()
    Kevin Wolf authored
    
    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: default avatarKevin Wolf <kwolf@redhat.com>
    Message-ID: <20231115172012.112727-4-kwolf@redhat.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
stream.c 13.22 KiB