On 2018-08-24 00:22, John Snow wrote: > Use the component callbacks; prepare, abort, and clean. > > NB: prepare is only called when the job has not yet failed; > and abort can be called after prepare. > > complete -> prepare -> abort -> clean > complete -> abort -> clean > > Signed-off-by: John Snow <js...@redhat.com> > --- > block/commit.c | 90 > ++++++++++++++++++++++++++++++++-------------------------- > 1 file changed, 49 insertions(+), 41 deletions(-) > > diff --git a/block/commit.c b/block/commit.c > index b6e8969877..9bf50385cf 100644 > --- a/block/commit.c > +++ b/block/commit.c
[...] > @@ -68,61 +69,65 @@ static int coroutine_fn commit_populate(BlockBackend *bs, > BlockBackend *base, [...] > +static void commit_abort(Job *job) > +{ > + CommitBlockJob *s = container_of(job, CommitBlockJob, common.job); > + BlockDriverState *top_bs = blk_bs(s->top); > + > + /* Make sure commit_top_bs and top stay around until bdrv_replace_node() > */ > + bdrv_ref(top_bs); > + bdrv_ref(s->commit_top_bs); > + > + if (s->base) { > + blk_unref(s->base); > } > > + /* free the blockers on the intermediate nodes so that bdrv_replace_nodes > + * can succeed */ > + block_job_remove_all_bdrv(&s->common); > + > + /* If bdrv_drop_intermediate() didn't already do that, remove the commit > + * filter driver from the backing chain. Do this as the final step so > that > + * the 'consistent read' permission can be granted. I'd suggest rewording this to "If bdrv_drop_intermediate() failed (or was not invoked at all), remove the commit filter driver from the backing chain now." Right now it sounds like maybe bdrv_drop_intermediate() removes the filter, and maybe it doesn't. But actually it is supposed to always remove it -- but it may fail, and then we have to force-remove the filter. Apart from that: Reviewed-by: Max Reitz <mre...@redhat.com> > + * > + * XXX Can (or should) we somehow keep 'consistent read' blocked even > + * after the failed/cancelled commit job is gone? If we already wrote > + * something to base, the intermediate images aren't valid any more. */ > + bdrv_child_try_set_perm(s->commit_top_bs->backing, 0, BLK_PERM_ALL, > + &error_abort); > + bdrv_replace_node(s->commit_top_bs, backing_bs(s->commit_top_bs), > + &error_abort); > + > + bdrv_unref(s->commit_top_bs); > + bdrv_unref(top_bs); > +}
signature.asc
Description: OpenPGP digital signature