]> git.proxmox.com Git - mirror_qemu.git/commit
job: Fix nested aio_poll() hanging in job_txn_apply
authorFam Zheng <famz@redhat.com>
Fri, 24 Aug 2018 02:43:42 +0000 (10:43 +0800)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 27 Mar 2019 05:29:12 +0000 (00:29 -0500)
commitef6de9e7203978733930512b88114a50e62fe76c
tree8d819b1c0968c5bbf348240fe0db918ef5c2ef8a
parent9e25063bb0039a9b9c5f91f8cc58f632f67af945
job: Fix nested aio_poll() hanging in job_txn_apply

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: Gu Nini <ngu@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 49880165a44f26dc84651858750facdee31f2513)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
job.c