child_role job already has .stay_at_node=true, so on bdrv_replace_node operation these child are unchanged. Make block job blk behave in same manner, to avoid inconsistent intermediate graph states and workarounds like in mirror.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> --- block/mirror.c | 6 +----- blockjob.c | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index f8bdb5b21b..23443116e4 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -713,12 +713,8 @@ static int mirror_exit_common(Job *job) &error_abort); bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort); - /* We just changed the BDS the job BB refers to (with either or both of the - * bdrv_replace_node() calls), so switch the BB back so the cleanup does - * the right thing. We don't need any permissions any more now. */ - blk_remove_bs(bjob->blk); + /* We don't need any permissions any more now. */ blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort); - blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort); bs_opaque->job = NULL; diff --git a/blockjob.c b/blockjob.c index 931d675c0c..f5c8d31491 100644 --- a/blockjob.c +++ b/blockjob.c @@ -398,7 +398,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, job_id = bdrv_get_device_name(bs); } - blk = blk_new(bdrv_get_aio_context(bs), perm, shared_perm); + blk = blk_new_pinned(bdrv_get_aio_context(bs), perm, shared_perm); ret = blk_insert_bs(blk, bs, errp); if (ret < 0) { blk_unref(blk); -- 2.18.0
