Skip to content
  • Fiona Ebner's avatar
    67446e60
    blockjob: drop AioContext lock before calling bdrv_graph_wrlock() · 67446e60
    Fiona Ebner authored
    
    
    Same rationale as in 31b2ddfe ("graph-lock: Unlock the AioContext
    while polling"). Otherwise, a deadlock can happen.
    
    The alternative would be to pass a BlockDriverState along to
    bdrv_graph_wrlock(), but there is no BlockDriverState readily
    available and it's also better conceptually, because the lock is held
    for the job.
    
    The function is always called with the job's AioContext lock held, via
    one of the .abort, .clean, .free or .prepare job driver functions.
    Thus, it's safe to drop it.
    
    While mirror_exit_common() does hold a second AioContext lock while
    calling block_job_remove_all_bdrv(), that is for the main thread's
    AioContext and does not need to be dropped (bdrv_graph_wrlock(bs) also
    skips dropping the lock if bdrv_get_aio_context(bs) ==
    qemu_get_aio_context()).
    
    Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarFiona Ebner <f.ebner@proxmox.com>
    Message-ID: <20231019131936.414246-2-f.ebner@proxmox.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    67446e60
    blockjob: drop AioContext lock before calling bdrv_graph_wrlock()
    Fiona Ebner authored
    
    
    Same rationale as in 31b2ddfe ("graph-lock: Unlock the AioContext
    while polling"). Otherwise, a deadlock can happen.
    
    The alternative would be to pass a BlockDriverState along to
    bdrv_graph_wrlock(), but there is no BlockDriverState readily
    available and it's also better conceptually, because the lock is held
    for the job.
    
    The function is always called with the job's AioContext lock held, via
    one of the .abort, .clean, .free or .prepare job driver functions.
    Thus, it's safe to drop it.
    
    While mirror_exit_common() does hold a second AioContext lock while
    calling block_job_remove_all_bdrv(), that is for the main thread's
    AioContext and does not need to be dropped (bdrv_graph_wrlock(bs) also
    skips dropping the lock if bdrv_get_aio_context(bs) ==
    qemu_get_aio_context()).
    
    Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarFiona Ebner <f.ebner@proxmox.com>
    Message-ID: <20231019131936.414246-2-f.ebner@proxmox.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading