From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v5 05/18] tests: adjust test-thread-pool to new aio_poll() semantics
Date: Mon, 1 Jul 2013 14:18:36 +0200 [thread overview]
Message-ID: <1372681129-18528-6-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1372681129-18528-1-git-send-email-stefanha@redhat.com>
aio_poll(ctx, true) will soon block when fd handlers have been set.
Previously aio_poll() would return early if all .io_flush() returned
false. This means we need to check the equivalent of the .io_flush()
condition *before* calling aio_poll(ctx, true) to avoid deadlock.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/test-thread-pool.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
index 22915aa..f0b2ef1 100644
--- a/tests/test-thread-pool.c
+++ b/tests/test-thread-pool.c
@@ -40,19 +40,13 @@ static void done_cb(void *opaque, int ret)
active--;
}
-/* Wait until all aio and bh activity has finished */
-static void qemu_aio_wait_all(void)
-{
- while (aio_poll(ctx, true)) {
- /* Do nothing */
- }
-}
-
static void test_submit(void)
{
WorkerTestData data = { .n = 0 };
thread_pool_submit(pool, worker_cb, &data);
- qemu_aio_wait_all();
+ while (data.n == 0) {
+ aio_poll(ctx, true);
+ }
g_assert_cmpint(data.n, ==, 1);
}
@@ -65,7 +59,9 @@ static void test_submit_aio(void)
/* The callbacks are not called until after the first wait. */
active = 1;
g_assert_cmpint(data.ret, ==, -EINPROGRESS);
- qemu_aio_wait_all();
+ while (data.ret == -EINPROGRESS) {
+ aio_poll(ctx, true);
+ }
g_assert_cmpint(active, ==, 0);
g_assert_cmpint(data.n, ==, 1);
g_assert_cmpint(data.ret, ==, 0);
@@ -103,7 +99,9 @@ static void test_submit_co(void)
/* qemu_aio_wait_all will execute the rest of the coroutine. */
- qemu_aio_wait_all();
+ while (data.ret == -EINPROGRESS) {
+ aio_poll(ctx, true);
+ }
/* Back here after the coroutine has finished. */
@@ -187,7 +185,9 @@ static void test_cancel(void)
}
/* Finish execution and execute any remaining callbacks. */
- qemu_aio_wait_all();
+ while (active > 0) {
+ aio_poll(ctx, true);
+ }
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
if (data[i].n == 3) {
--
1.8.1.4
next prev parent reply other threads:[~2013-07-01 12:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 12:18 [Qemu-devel] [PATCH v5 00/18] aio: drop io_flush() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 01/18] block: ensure bdrv_drain_all() works during bdrv_delete() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 02/18] block: stop relying on io_flush() in bdrv_drain_all() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 03/18] dataplane/virtio-blk: check exit conditions before aio_poll() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 04/18] tests: adjust test-aio to new aio_poll() semantics Stefan Hajnoczi
2013-07-01 12:18 ` Stefan Hajnoczi [this message]
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 06/18] aio: stop using .io_flush() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 07/18] block/curl: drop curl_aio_flush() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 08/18] block/gluster: drop qemu_gluster_aio_flush_cb() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 09/18] block/iscsi: drop iscsi_process_flush() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 10/18] block/linux-aio: drop qemu_laio_completion_cb() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 11/18] block/nbd: drop nbd_have_request() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 12/18] block/rbd: drop qemu_rbd_aio_flush_cb() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 13/18] block/sheepdog: drop have_co_req() and aio_flush_request() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 14/18] block/ssh: drop return_true() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 15/18] dataplane/virtio-blk: drop flush_true() and flush_io() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 16/18] thread-pool: drop thread_pool_active() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 17/18] tests: drop event_active_cb() Stefan Hajnoczi
2013-07-01 12:18 ` [Qemu-devel] [PATCH v5 18/18] aio: drop io_flush argument Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372681129-18528-6-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).