test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level()
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 <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
4cf077b59f
commit
ecc1a5c790
@ -636,6 +636,17 @@ static void test_iothread_aio_cb(void *opaque, int ret)
|
|||||||
qemu_event_set(&done_event);
|
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.
|
* 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.
|
* 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_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
|
/* 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,
|
* will make sure that it has completed as far as the BDS is concerned,
|
||||||
* but the drain in this thread can continue immediately after
|
* but the drain in this thread can continue immediately after
|
||||||
|
Loading…
x
Reference in New Issue
Block a user