Blame SOURCES/kvm-test-bdrv-drain-Test-AIO_WAIT_WHILE-in-completion-ca.patch

357786
From c6dae9ed2996e40bfdcf6c680bd481c43182fb3d Mon Sep 17 00:00:00 2001
357786
From: Kevin Wolf <kwolf@redhat.com>
357786
Date: Fri, 14 Sep 2018 10:55:30 +0200
357786
Subject: [PATCH 39/49] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion
357786
 callback
357786
357786
RH-Author: Kevin Wolf <kwolf@redhat.com>
357786
Message-id: <20180914105540.18077-33-kwolf@redhat.com>
357786
Patchwork-id: 82181
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 32/42] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback
357786
Bugzilla: 1601212
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Fam Zheng <famz@redhat.com>
357786
357786
This is a regression test for a deadlock that occurred in block job
357786
completion callbacks (via job_defer_to_main_loop) because the AioContext
357786
lock was taken twice: once in job_finish_sync() and then again in
357786
job_defer_to_main_loop_bh(). This would cause AIO_WAIT_WHILE() to hang.
357786
357786
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
357786
Reviewed-by: Fam Zheng <famz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 tests/test-bdrv-drain.c | 10 ++++++++++
357786
 1 file changed, 10 insertions(+)
357786
357786
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
357786
index 3cf3ba3..05f3b55 100644
357786
--- a/tests/test-bdrv-drain.c
357786
+++ b/tests/test-bdrv-drain.c
357786
@@ -774,6 +774,15 @@ typedef struct TestBlockJob {
357786
     bool should_complete;
357786
 } TestBlockJob;
357786
 
357786
+static int test_job_prepare(Job *job)
357786
+{
357786
+    TestBlockJob *s = container_of(job, TestBlockJob, common.job);
357786
+
357786
+    /* Provoke an AIO_WAIT_WHILE() call to verify there is no deadlock */
357786
+    blk_flush(s->common.blk);
357786
+    return 0;
357786
+}
357786
+
357786
 static int coroutine_fn test_job_run(Job *job, Error **errp)
357786
 {
357786
     TestBlockJob *s = container_of(job, TestBlockJob, common.job);
357786
@@ -804,6 +813,7 @@ BlockJobDriver test_job_driver = {
357786
         .drain          = block_job_drain,
357786
         .run            = test_job_run,
357786
         .complete       = test_job_complete,
357786
+        .prepare        = test_job_prepare,
357786
     },
357786
 };
357786
 
357786
-- 
357786
1.8.3.1
357786