yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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