From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 06/13] tests: Lock AioContexts in test-block-iothread
Date: Fri, 19 Jul 2019 15:43:38 +0200 [thread overview]
Message-ID: <20190719134345.23526-7-kwolf@redhat.com> (raw)
In-Reply-To: <20190719134345.23526-1-kwolf@redhat.com>
From: Max Reitz <mreitz@redhat.com>
When changing a node's AioContext, the caller must acquire the old
AioContext (unless it currently runs in that old context). Therefore,
unless the node currently is in the main context, we always have to
acquire the old context around calls that may change a node's
AioContext.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/test-block-iothread.c | 40 ++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c
index 79d9cf8a57..1949d5e61a 100644
--- a/tests/test-block-iothread.c
+++ b/tests/test-block-iothread.c
@@ -348,8 +348,8 @@ static void test_sync_op(const void *opaque)
if (t->blkfn) {
t->blkfn(blk);
}
- aio_context_release(ctx);
blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort);
+ aio_context_release(ctx);
bdrv_unref(bs);
blk_unref(blk);
@@ -476,6 +476,7 @@ static void test_propagate_basic(void)
{
IOThread *iothread = iothread_new();
AioContext *ctx = iothread_get_aio_context(iothread);
+ AioContext *main_ctx;
BlockBackend *blk;
BlockDriverState *bs_a, *bs_b, *bs_verify;
QDict *options;
@@ -504,12 +505,14 @@ static void test_propagate_basic(void)
g_assert(bdrv_get_aio_context(bs_b) == ctx);
/* Switch the AioContext back */
- ctx = qemu_get_aio_context();
- blk_set_aio_context(blk, ctx, &error_abort);
- g_assert(blk_get_aio_context(blk) == ctx);
- g_assert(bdrv_get_aio_context(bs_a) == ctx);
- g_assert(bdrv_get_aio_context(bs_verify) == ctx);
- g_assert(bdrv_get_aio_context(bs_b) == ctx);
+ main_ctx = qemu_get_aio_context();
+ aio_context_acquire(ctx);
+ blk_set_aio_context(blk, main_ctx, &error_abort);
+ aio_context_release(ctx);
+ g_assert(blk_get_aio_context(blk) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_a) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_verify) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_b) == main_ctx);
bdrv_unref(bs_verify);
bdrv_unref(bs_b);
@@ -534,6 +537,7 @@ static void test_propagate_diamond(void)
{
IOThread *iothread = iothread_new();
AioContext *ctx = iothread_get_aio_context(iothread);
+ AioContext *main_ctx;
BlockBackend *blk;
BlockDriverState *bs_a, *bs_b, *bs_c, *bs_verify;
QDict *options;
@@ -573,13 +577,15 @@ static void test_propagate_diamond(void)
g_assert(bdrv_get_aio_context(bs_c) == ctx);
/* Switch the AioContext back */
- ctx = qemu_get_aio_context();
- blk_set_aio_context(blk, ctx, &error_abort);
- g_assert(blk_get_aio_context(blk) == ctx);
- g_assert(bdrv_get_aio_context(bs_verify) == ctx);
- g_assert(bdrv_get_aio_context(bs_a) == ctx);
- g_assert(bdrv_get_aio_context(bs_b) == ctx);
- g_assert(bdrv_get_aio_context(bs_c) == ctx);
+ main_ctx = qemu_get_aio_context();
+ aio_context_acquire(ctx);
+ blk_set_aio_context(blk, main_ctx, &error_abort);
+ aio_context_release(ctx);
+ g_assert(blk_get_aio_context(blk) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_verify) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_a) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_b) == main_ctx);
+ g_assert(bdrv_get_aio_context(bs_c) == main_ctx);
blk_unref(blk);
bdrv_unref(bs_verify);
@@ -685,7 +691,9 @@ static void test_attach_second_node(void)
g_assert(bdrv_get_aio_context(bs) == ctx);
g_assert(bdrv_get_aio_context(filter) == ctx);
+ aio_context_acquire(ctx);
blk_set_aio_context(blk, main_ctx, &error_abort);
+ aio_context_release(ctx);
g_assert(blk_get_aio_context(blk) == main_ctx);
g_assert(bdrv_get_aio_context(bs) == main_ctx);
g_assert(bdrv_get_aio_context(filter) == main_ctx);
@@ -712,7 +720,9 @@ static void test_attach_preserve_blk_ctx(void)
g_assert(bdrv_get_aio_context(bs) == ctx);
/* Remove the node again */
+ aio_context_acquire(ctx);
blk_remove_bs(blk);
+ aio_context_release(ctx);
g_assert(blk_get_aio_context(blk) == ctx);
g_assert(bdrv_get_aio_context(bs) == qemu_get_aio_context());
@@ -721,7 +731,9 @@ static void test_attach_preserve_blk_ctx(void)
g_assert(blk_get_aio_context(blk) == ctx);
g_assert(bdrv_get_aio_context(bs) == ctx);
+ aio_context_acquire(ctx);
blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort);
+ aio_context_release(ctx);
bdrv_unref(bs);
blk_unref(blk);
}
--
2.20.1
next prev parent reply other threads:[~2019-07-19 13:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-19 13:43 [Qemu-devel] [PULL 00/13] Block layer patches Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 01/13] iotests: Set read-zeroes on in null block driver for Valgrind Kevin Wolf
2019-07-24 7:18 ` Christian Borntraeger
2019-07-24 7:30 ` Andrey Shinkevich
2019-07-24 7:33 ` Christian Borntraeger
2019-07-24 7:37 ` Andrey Shinkevich
2019-07-24 7:38 ` Kevin Wolf
2019-07-24 7:57 ` Andrey Shinkevich
2019-07-24 8:05 ` Kevin Wolf
2019-07-24 8:23 ` Andrey Shinkevich
2019-07-19 13:43 ` [Qemu-devel] [PULL 02/13] block: Introduce BdrvChild.parent_quiesce_counter Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 03/13] tests: Add job commit by drained_end test Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 04/13] block: Add @drained_end_counter Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 05/13] block: Make bdrv_parent_drained_[^_]*() static Kevin Wolf
2019-07-19 13:43 ` Kevin Wolf [this message]
2019-07-19 13:43 ` [Qemu-devel] [PULL 07/13] block: Do not poll in bdrv_do_drained_end() Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 08/13] tests: Extend commit by drained_end test Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 09/13] block: Loop unsafely in bdrv*drained_end() Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 10/13] iotests: Add @has_quit to vm.shutdown() Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 11/13] iotests: Test commit with a filter on the chain Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 12/13] vl: Drain before (block) job cancel when quitting Kevin Wolf
2019-07-19 13:43 ` [Qemu-devel] [PULL 13/13] iotests: Test quitting with job on throttled node Kevin Wolf
2019-07-22 9:11 ` [Qemu-devel] [PULL 00/13] Block layer patches Peter Maydell
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=20190719134345.23526-7-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--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).