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

26ba25
From 1169efb3bbd8600721e981c5992962b4563a2d6a Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Wed, 10 Oct 2018 20:22:01 +0100
26ba25
Subject: [PATCH 35/49] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion
26ba25
 callback
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20181010202213.7372-23-kwolf@redhat.com>
26ba25
Patchwork-id: 82611
26ba25
O-Subject: [RHEL-8 qemu-kvm PATCH 32/44] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback
26ba25
Bugzilla: 1637976
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
26ba25
This is a regression test for a deadlock that occurred in block job
26ba25
completion callbacks (via job_defer_to_main_loop) because the AioContext
26ba25
lock was taken twice: once in job_finish_sync() and then again in
26ba25
job_defer_to_main_loop_bh(). This would cause AIO_WAIT_WHILE() to hang.
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Reviewed-by: Fam Zheng <famz@redhat.com>
26ba25
(cherry picked from commit ae23dde9dd486e57e152a0ebc9802caddedc45fc)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 tests/test-bdrv-drain.c | 10 ++++++++++
26ba25
 1 file changed, 10 insertions(+)
26ba25
26ba25
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
26ba25
index 3cf3ba3..05f3b55 100644
26ba25
--- a/tests/test-bdrv-drain.c
26ba25
+++ b/tests/test-bdrv-drain.c
26ba25
@@ -774,6 +774,15 @@ typedef struct TestBlockJob {
26ba25
     bool should_complete;
26ba25
 } TestBlockJob;
26ba25
 
26ba25
+static int test_job_prepare(Job *job)
26ba25
+{
26ba25
+    TestBlockJob *s = container_of(job, TestBlockJob, common.job);
26ba25
+
26ba25
+    /* Provoke an AIO_WAIT_WHILE() call to verify there is no deadlock */
26ba25
+    blk_flush(s->common.blk);
26ba25
+    return 0;
26ba25
+}
26ba25
+
26ba25
 static int coroutine_fn test_job_run(Job *job, Error **errp)
26ba25
 {
26ba25
     TestBlockJob *s = container_of(job, TestBlockJob, common.job);
26ba25
@@ -804,6 +813,7 @@ BlockJobDriver test_job_driver = {
26ba25
         .drain          = block_job_drain,
26ba25
         .run            = test_job_run,
26ba25
         .complete       = test_job_complete,
26ba25
+        .prepare        = test_job_prepare,
26ba25
     },
26ba25
 };
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25