* [Qemu-devel] [PATCH v2] job: Fix nested aio_poll() hanging in job_txn_apply
@ 2018-08-24 2:43 Fam Zheng
2018-09-04 1:02 ` [Qemu-devel] [Qemu-stable] " Fam Zheng
2018-09-10 15:27 ` [Qemu-devel] " Kevin Wolf
0 siblings, 2 replies; 3+ messages in thread
From: Fam Zheng @ 2018-08-24 2:43 UTC (permalink / raw)
To: qemu-devel
Cc: kwolf, qemu-block, qemu-stable, Jeff Cody, mreitz, pbonzini,
eblake
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>
---
v2: Add Eric's r-b and some more details in commit message.
---
job.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/job.c b/job.c
index e36ebaafd8..a3bec7fb22 100644
--- a/job.c
+++ b/job.c
@@ -136,21 +136,13 @@ static void job_txn_del_job(Job *job)
}
}
-static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock)
+static int job_txn_apply(JobTxn *txn, int fn(Job *))
{
- AioContext *ctx;
Job *job, *next;
int rc = 0;
QLIST_FOREACH_SAFE(job, &txn->jobs, txn_list, next) {
- if (lock) {
- ctx = job->aio_context;
- aio_context_acquire(ctx);
- }
rc = fn(job);
- if (lock) {
- aio_context_release(ctx);
- }
if (rc) {
break;
}
@@ -807,11 +799,11 @@ static void job_do_finalize(Job *job)
assert(job && job->txn);
/* prepare the transaction to complete */
- rc = job_txn_apply(job->txn, job_prepare, true);
+ rc = job_txn_apply(job->txn, job_prepare);
if (rc) {
job_completed_txn_abort(job);
} else {
- job_txn_apply(job->txn, job_finalize_single, true);
+ job_txn_apply(job->txn, job_finalize_single);
}
}
@@ -857,10 +849,10 @@ static void job_completed_txn_success(Job *job)
assert(other_job->ret == 0);
}
- job_txn_apply(txn, job_transition_to_pending, false);
+ job_txn_apply(txn, job_transition_to_pending);
/* If no jobs need manual finalization, automatically do so */
- if (job_txn_apply(txn, job_needs_finalize, false) == 0) {
+ if (job_txn_apply(txn, job_needs_finalize) == 0) {
job_do_finalize(job);
}
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-stable] [PATCH v2] job: Fix nested aio_poll() hanging in job_txn_apply
2018-08-24 2:43 [Qemu-devel] [PATCH v2] job: Fix nested aio_poll() hanging in job_txn_apply Fam Zheng
@ 2018-09-04 1:02 ` Fam Zheng
2018-09-10 15:27 ` [Qemu-devel] " Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2018-09-04 1:02 UTC (permalink / raw)
To: qemu-devel
Cc: kwolf, qemu-block, Jeff Cody, qemu-stable, mreitz, pbonzini,
eblake
On Fri, 08/24 10:43, Fam Zheng wrote:
> 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>
Ping?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] job: Fix nested aio_poll() hanging in job_txn_apply
2018-08-24 2:43 [Qemu-devel] [PATCH v2] job: Fix nested aio_poll() hanging in job_txn_apply Fam Zheng
2018-09-04 1:02 ` [Qemu-devel] [Qemu-stable] " Fam Zheng
@ 2018-09-10 15:27 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2018-09-10 15:27 UTC (permalink / raw)
To: Fam Zheng
Cc: qemu-devel, qemu-block, qemu-stable, Jeff Cody, mreitz, pbonzini,
eblake
Am 24.08.2018 um 04:43 hat Fam Zheng geschrieben:
> 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>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-10 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-24 2:43 [Qemu-devel] [PATCH v2] job: Fix nested aio_poll() hanging in job_txn_apply Fam Zheng
2018-09-04 1:02 ` [Qemu-devel] [Qemu-stable] " Fam Zheng
2018-09-10 15:27 ` [Qemu-devel] " Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).