Skip to content
  • Fam Zheng's avatar
    49880165
    job: Fix nested aio_poll() hanging in job_txn_apply · 49880165
    Fam Zheng authored
    
    
    All callers have acquired ctx already. Doing that again results in
    aio_poll() hang. This fixes the problem that a BDRV_POLL_WHILE() in the
    callback cannot make progress because ctx is recursively locked, for
    example, when drive-backup finishes.
    
    There are two callers of job_finalize():
    
        fam@lemon:~/work/qemu [master]$ git grep -w -A1 '^\s*job_finalize'
        blockdev.c:    job_finalize(&job->job, errp);
        blockdev.c-    aio_context_release(aio_context);
        --
        job-qmp.c:    job_finalize(job, errp);
        job-qmp.c-    aio_context_release(aio_context);
        --
        tests/test-blockjob.c:    job_finalize(&job->job, &error_abort);
        tests/test-blockjob.c-    assert(job->job.status == JOB_STATUS_CONCLUDED);
    
    Ignoring the test, it's easy to see both callers to job_finalize (and
    job_do_finalize) have acquired the context.
    
    Cc: qemu-stable@nongnu.org
    Reported-by: default avatarGu Nini <ngu@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Signed-off-by: default avatarFam Zheng <famz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    49880165
    job: Fix nested aio_poll() hanging in job_txn_apply
    Fam Zheng authored
    
    
    All callers have acquired ctx already. Doing that again results in
    aio_poll() hang. This fixes the problem that a BDRV_POLL_WHILE() in the
    callback cannot make progress because ctx is recursively locked, for
    example, when drive-backup finishes.
    
    There are two callers of job_finalize():
    
        fam@lemon:~/work/qemu [master]$ git grep -w -A1 '^\s*job_finalize'
        blockdev.c:    job_finalize(&job->job, errp);
        blockdev.c-    aio_context_release(aio_context);
        --
        job-qmp.c:    job_finalize(job, errp);
        job-qmp.c-    aio_context_release(aio_context);
        --
        tests/test-blockjob.c:    job_finalize(&job->job, &error_abort);
        tests/test-blockjob.c-    assert(job->job.status == JOB_STATUS_CONCLUDED);
    
    Ignoring the test, it's easy to see both callers to job_finalize (and
    job_do_finalize) have acquired the context.
    
    Cc: qemu-stable@nongnu.org
    Reported-by: default avatarGu Nini <ngu@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Signed-off-by: default avatarFam Zheng <famz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading