Skip to content
  • Paolo Bonzini's avatar
    d79df2a2
    blockjob: avoid recursive AioContext locking · d79df2a2
    Paolo Bonzini authored
    
    
    Streaming or any other block job hangs when performed on a block device
    that has a non-default iothread.  This happens because the AioContext
    is acquired twice by block_job_defer_to_main_loop_bh and then released
    only once by BDRV_POLL_WHILE.  (Insert rants on recursive mutexes, which
    unfortunately are a temporary but necessary evil for iothreads at the
    moment).
    
    Luckily, the reason for the double acquisition is simple; the function
    acquires the AioContext for both the job iothread and the BDS iothread,
    in case the BDS iothread was changed while the job was running.  It
    is therefore enough to skip the second acquisition when the two
    AioContexts are one and the same.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
    Message-id: 1490118490-5597-1-git-send-email-pbonzini@redhat.com
    Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
    d79df2a2
    blockjob: avoid recursive AioContext locking
    Paolo Bonzini authored
    
    
    Streaming or any other block job hangs when performed on a block device
    that has a non-default iothread.  This happens because the AioContext
    is acquired twice by block_job_defer_to_main_loop_bh and then released
    only once by BDRV_POLL_WHILE.  (Insert rants on recursive mutexes, which
    unfortunately are a temporary but necessary evil for iothreads at the
    moment).
    
    Luckily, the reason for the double acquisition is simple; the function
    acquires the AioContext for both the job iothread and the BDS iothread,
    in case the BDS iothread was changed while the job was running.  It
    is therefore enough to skip the second acquisition when the two
    AioContexts are one and the same.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
    Message-id: 1490118490-5597-1-git-send-email-pbonzini@redhat.com
    Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
Loading