|
|
383d26 |
From 2a9333d5c086c587c527afe9dc9936e3a1658e84 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Date: Fri, 14 Sep 2018 10:55:23 +0200
|
|
|
383d26 |
Subject: [PATCH 32/49] job: Fix nested aio_poll() hanging in job_txn_apply
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Message-id: <20180914105540.18077-26-kwolf@redhat.com>
|
|
|
383d26 |
Patchwork-id: 82177
|
|
|
383d26 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 25/42] job: Fix nested aio_poll() hanging in job_txn_apply
|
|
|
383d26 |
Bugzilla: 1601212
|
|
|
383d26 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
All callers have acquired ctx already. Doing that again results in
|
|
|
383d26 |
aio_poll() hang. This fixes the problem that a BDRV_POLL_WHILE() in the
|
|
|
383d26 |
callback cannot make progress because ctx is recursively locked, for
|
|
|
383d26 |
example, when drive-backup finishes.
|
|
|
383d26 |
|
|
|
383d26 |
There are two callers of job_finalize():
|
|
|
383d26 |
|
|
|
383d26 |
fam@lemon:~/work/qemu [master]$ git grep -w -A1 '^\s*job_finalize'
|
|
|
383d26 |
blockdev.c: job_finalize(&job->job, errp);
|
|
|
383d26 |
blockdev.c- aio_context_release(aio_context);
|
|
|
383d26 |
--
|
|
|
383d26 |
job-qmp.c: job_finalize(job, errp);
|
|
|
383d26 |
job-qmp.c- aio_context_release(aio_context);
|
|
|
383d26 |
--
|
|
|
383d26 |
tests/test-blockjob.c: job_finalize(&job->job, &error_abort);
|
|
|
383d26 |
tests/test-blockjob.c- assert(job->job.status == JOB_STATUS_CONCLUDED);
|
|
|
383d26 |
|
|
|
383d26 |
Ignoring the test, it's easy to see both callers to job_finalize (and
|
|
|
383d26 |
job_do_finalize) have acquired the context.
|
|
|
383d26 |
|
|
|
383d26 |
Cc: qemu-stable@nongnu.org
|
|
|
383d26 |
Reported-by: Gu Nini <ngu@redhat.com>
|
|
|
383d26 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
job.c | 18 +++++-------------
|
|
|
383d26 |
1 file changed, 5 insertions(+), 13 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/job.c b/job.c
|
|
|
383d26 |
index dfba4bc..5d117fb 100644
|
|
|
383d26 |
--- a/job.c
|
|
|
383d26 |
+++ b/job.c
|
|
|
383d26 |
@@ -136,21 +136,13 @@ static void job_txn_del_job(Job *job)
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
-static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock)
|
|
|
383d26 |
+static int job_txn_apply(JobTxn *txn, int fn(Job *))
|
|
|
383d26 |
{
|
|
|
383d26 |
- AioContext *ctx;
|
|
|
383d26 |
Job *job, *next;
|
|
|
383d26 |
int rc = 0;
|
|
|
383d26 |
|
|
|
383d26 |
QLIST_FOREACH_SAFE(job, &txn->jobs, txn_list, next) {
|
|
|
383d26 |
- if (lock) {
|
|
|
383d26 |
- ctx = job->aio_context;
|
|
|
383d26 |
- aio_context_acquire(ctx);
|
|
|
383d26 |
- }
|
|
|
383d26 |
rc = fn(job);
|
|
|
383d26 |
- if (lock) {
|
|
|
383d26 |
- aio_context_release(ctx);
|
|
|
383d26 |
- }
|
|
|
383d26 |
if (rc) {
|
|
|
383d26 |
break;
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -775,11 +767,11 @@ static void job_do_finalize(Job *job)
|
|
|
383d26 |
assert(job && job->txn);
|
|
|
383d26 |
|
|
|
383d26 |
/* prepare the transaction to complete */
|
|
|
383d26 |
- rc = job_txn_apply(job->txn, job_prepare, true);
|
|
|
383d26 |
+ rc = job_txn_apply(job->txn, job_prepare);
|
|
|
383d26 |
if (rc) {
|
|
|
383d26 |
job_completed_txn_abort(job);
|
|
|
383d26 |
} else {
|
|
|
383d26 |
- job_txn_apply(job->txn, job_finalize_single, true);
|
|
|
383d26 |
+ job_txn_apply(job->txn, job_finalize_single);
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
@@ -825,10 +817,10 @@ static void job_completed_txn_success(Job *job)
|
|
|
383d26 |
assert(other_job->ret == 0);
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
- job_txn_apply(txn, job_transition_to_pending, false);
|
|
|
383d26 |
+ job_txn_apply(txn, job_transition_to_pending);
|
|
|
383d26 |
|
|
|
383d26 |
/* If no jobs need manual finalization, automatically do so */
|
|
|
383d26 |
- if (job_txn_apply(txn, job_needs_finalize, false) == 0) {
|
|
|
383d26 |
+ if (job_txn_apply(txn, job_needs_finalize) == 0) {
|
|
|
383d26 |
job_do_finalize(job);
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|