@@ -1316,7 +1316,6 @@ struct detach_by_parent_data {
BdrvChild *child_b;
BlockDriverState *c;
BdrvChild *child_c;
- bool by_parent_cb;
};
static struct detach_by_parent_data detach_by_parent_data;
@@ -1334,12 +1333,7 @@ static void detach_indirect_bh(void *opaque)
static void detach_by_parent_aio_cb(void *opaque, int ret)
{
- struct detach_by_parent_data *data = &detach_by_parent_data;
-
g_assert_cmpint(ret, ==, 0);
- if (data->by_parent_cb) {
- detach_indirect_bh(data);
- }
}
static void detach_by_driver_cb_drained_begin(BdrvChild *child)
@@ -1358,33 +1352,25 @@ static BdrvChildClass detach_by_driver_cb_class;
* \ / \
* A B C
*
- * by_parent_cb == true: Test that parent callbacks don't poll
- *
- * PA has a pending write request whose callback changes the child nodes of
- * PB: It removes B and adds C instead. The subtree of PB is drained, which
- * will indirectly drain the write request, too.
- *
- * by_parent_cb == false: Test that bdrv_drain_invoke() doesn't poll
+ * Test that bdrv_drain_invoke() doesn't poll
*
* PA's BdrvChildClass has a .drained_begin callback that schedules a BH
* that does the same graph change. If bdrv_drain_invoke() calls it, the
* state is messed up, but if it is only polled in the single
* BDRV_POLL_WHILE() at the end of the drain, this should work fine.
*/
-static void test_detach_indirect(bool by_parent_cb)
+static void test_detach_indirect(void)
{
BlockBackend *blk;
BlockDriverState *parent_a, *parent_b, *a, *b, *c;
BdrvChild *child_a, *child_b;
BlockAIOCB *acb;
+ BDRVTestState *s;
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, 0);
- if (!by_parent_cb) {
- detach_by_driver_cb_class = child_of_bds;
- detach_by_driver_cb_class.drained_begin =
- detach_by_driver_cb_drained_begin;
- }
+ detach_by_driver_cb_class = child_of_bds;
+ detach_by_driver_cb_class.drained_begin = detach_by_driver_cb_drained_begin;
/* Create all involved nodes */
parent_a = bdrv_new_open_driver(&bdrv_test, "parent-a", BDRV_O_RDWR,
@@ -1403,10 +1389,8 @@ static void test_detach_indirect(bool by_parent_cb)
/* If we want to get bdrv_drain_invoke() to call aio_poll(), the driver
* callback must not return immediately. */
- if (!by_parent_cb) {
- BDRVTestState *s = parent_a->opaque;
- s->sleep_in_drain_begin = true;
- }
+ s = parent_a->opaque;
+ s->sleep_in_drain_begin = true;
/* Set child relationships */
bdrv_ref(b);
@@ -1418,7 +1402,7 @@ static void test_detach_indirect(bool by_parent_cb)
bdrv_ref(a);
bdrv_attach_child(parent_a, a, "PA-A",
- by_parent_cb ? &child_of_bds : &detach_by_driver_cb_class,
+ &detach_by_driver_cb_class,
BDRV_CHILD_DATA, &error_abort);
g_assert_cmpint(parent_a->refcnt, ==, 1);
@@ -1436,7 +1420,6 @@ static void test_detach_indirect(bool by_parent_cb)
.parent_b = parent_b,
.child_b = child_b,
.c = c,
- .by_parent_cb = by_parent_cb,
};
acb = blk_aio_preadv(blk, 0, &qiov, 0, detach_by_parent_aio_cb, NULL);
g_assert(acb != NULL);
@@ -1475,14 +1458,9 @@ static void test_detach_indirect(bool by_parent_cb)
bdrv_unref(c);
}
-static void test_detach_by_parent_cb(void)
-{
- test_detach_indirect(true);
-}
-
static void test_detach_by_driver_cb(void)
{
- test_detach_indirect(false);
+ test_detach_indirect();
}
static void test_append_to_drained(void)
@@ -2236,7 +2214,6 @@ int main(int argc, char **argv)
g_test_add_func("/bdrv-drain/detach/drain_all", test_detach_by_drain_all);
g_test_add_func("/bdrv-drain/detach/drain", test_detach_by_drain);
g_test_add_func("/bdrv-drain/detach/drain_subtree", test_detach_by_drain_subtree);
- g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
g_test_add_func("/bdrv-drain/detach/driver_cb", test_detach_by_driver_cb);
g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained);