[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 14/19] test-bdrv-drain: Test nested poll in bdrv_
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v3 14/19] test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level() |
Date: |
Thu, 20 Sep 2018 18:19:53 +0200 |
This is a regression test for a deadlock that could occur in callbacks
called from the aio_poll() in bdrv_drain_poll_top_level(). The
AioContext lock wasn't released and therefore would be taken a second
time in the callback. This would cause a possible AIO_WAIT_WHILE() in
the callback to hang.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
---
tests/test-bdrv-drain.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index c3c17b9ff7..e105c0ae84 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -636,6 +636,17 @@ static void test_iothread_aio_cb(void *opaque, int ret)
qemu_event_set(&done_event);
}
+static void test_iothread_main_thread_bh(void *opaque)
+{
+ struct test_iothread_data *data = opaque;
+
+ /* Test that the AioContext is not yet locked in a random BH that is
+ * executed during drain, otherwise this would deadlock. */
+ aio_context_acquire(bdrv_get_aio_context(data->bs));
+ bdrv_flush(data->bs);
+ aio_context_release(bdrv_get_aio_context(data->bs));
+}
+
/*
* Starts an AIO request on a BDS that runs in the AioContext of iothread 1.
* The request involves a BH on iothread 2 before it can complete.
@@ -705,6 +716,8 @@ static void test_iothread_common(enum drain_type
drain_type, int drain_thread)
aio_context_acquire(ctx_a);
}
+ aio_bh_schedule_oneshot(ctx_a, test_iothread_main_thread_bh, &data);
+
/* The request is running on the IOThread a. Draining its block device
* will make sure that it has completed as far as the BDS is concerned,
* but the drain in this thread can continue immediately after
--
2.13.6
- [Qemu-devel] [PATCH v3 05/19] test-blockjob: Acquire AioContext around job_cancel_sync(), (continued)
- [Qemu-devel] [PATCH v3 05/19] test-blockjob: Acquire AioContext around job_cancel_sync(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 04/19] test-bdrv-drain: Drain with block jobs in an I/O thread, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 06/19] job: Use AIO_WAIT_WHILE() in job_finish_sync(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 09/19] block-backend: Add .drained_poll callback, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 11/19] block-backend: Decrease in_flight only after callback, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 08/19] block: Add missing locking in bdrv_co_drain_bh_cb(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 12/19] blockjob: Lie better in child_job_drained_poll(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 13/19] block: Remove aio_poll() in bdrv_drain_poll variants, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 10/19] block-backend: Fix potential double blk_delete(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 14/19] test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level(),
Kevin Wolf <=
- [Qemu-devel] [PATCH v3 07/19] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 15/19] job: Avoid deadlocks in job_completed_txn_abort(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 16/19] test-bdrv-drain: AIO_WAIT_WHILE() in job .commit/.abort, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 17/19] test-bdrv-drain: Fix outdated comments, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 19/19] test-bdrv-drain: Test draining job source child and parent, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 18/19] block: Use a single global AioWait, Kevin Wolf, 2018/09/20