thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-test-bdrv-drain-Test-nested-poll-in-bdrv_drain_poll_.patch

ae23c9
From ad9c7d63179e24afa5357ada56fccaeab10545c7 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Wed, 10 Oct 2018 20:22:08 +0100
ae23c9
Subject: [PATCH 42/49] test-bdrv-drain: Test nested poll in
ae23c9
 bdrv_drain_poll_top_level()
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20181010202213.7372-30-kwolf@redhat.com>
ae23c9
Patchwork-id: 82618
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH 39/44] test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level()
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 could occur in callbacks
ae23c9
called from the aio_poll() in bdrv_drain_poll_top_level(). The
ae23c9
AioContext lock wasn't released and therefore would be taken a second
ae23c9
time in the callback. This would cause a possible AIO_WAIT_WHILE() in
ae23c9
the callback 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 ecc1a5c790cf2c7732cb9755ca388c2fe108d1a1)
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 | 13 +++++++++++++
ae23c9
 1 file changed, 13 insertions(+)
ae23c9
ae23c9
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
ae23c9
index 05f3b55..f4b57f7 100644
ae23c9
--- a/tests/test-bdrv-drain.c
ae23c9
+++ b/tests/test-bdrv-drain.c
ae23c9
@@ -636,6 +636,17 @@ static void test_iothread_aio_cb(void *opaque, int ret)
ae23c9
     qemu_event_set(&done_event);
ae23c9
 }
ae23c9
 
ae23c9
+static void test_iothread_main_thread_bh(void *opaque)
ae23c9
+{
ae23c9
+    struct test_iothread_data *data = opaque;
ae23c9
+
ae23c9
+    /* Test that the AioContext is not yet locked in a random BH that is
ae23c9
+     * executed during drain, otherwise this would deadlock. */
ae23c9
+    aio_context_acquire(bdrv_get_aio_context(data->bs));
ae23c9
+    bdrv_flush(data->bs);
ae23c9
+    aio_context_release(bdrv_get_aio_context(data->bs));
ae23c9
+}
ae23c9
+
ae23c9
 /*
ae23c9
  * Starts an AIO request on a BDS that runs in the AioContext of iothread 1.
ae23c9
  * The request involves a BH on iothread 2 before it can complete.
ae23c9
@@ -705,6 +716,8 @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
ae23c9
             aio_context_acquire(ctx_a);
ae23c9
         }
ae23c9
 
ae23c9
+        aio_bh_schedule_oneshot(ctx_a, test_iothread_main_thread_bh, &data);
ae23c9
+
ae23c9
         /* The request is running on the IOThread a. Draining its block device
ae23c9
          * will make sure that it has completed as far as the BDS is concerned,
ae23c9
          * but the drain in this thread can continue immediately after
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9