On Wed, 09/10 10:20, Paolo Bonzini wrote:
> Il 10/09/2014 07:59, Fam Zheng ha scritto:
> > @@ -4679,6 +4679,9 @@ static void bdrv_aio_cancel_em(BlockDriverAIOCB 
> > *blockacb)
> >  {
> >      BlockDriverAIOCBSync *acb =
> >          container_of(blockacb, BlockDriverAIOCBSync, common);
> > +
> > +    acb->ret = -ECANCELED;
> > +    acb->common.cb(acb->common.opaque, acb->ret);
> >      qemu_bh_delete(acb->bh);
> >      acb->bh = NULL;
> >      qemu_aio_release(acb);
> 
> This could call the callback before I/O is finished.  I/O can then
> complete and write to disk stuff that was not meant to be written.

I think the request is already completed when bdrv_aio_rw_vector returns this
blockacb. I shouldn't override the return code anyway, but perhaps a nop
bdrv_aio_cancel_em is better.

> 
> I think there is a pre-existing bug, which should be fixed with a "bool
> *done" member similar to BlockDriverAIOCBCoroutine's.  But for the sake
> of conversion to async cancellation, you can just empty bdrv_aio_cancel_em.
> 

BTW, why is it "bool *done" instead of just "bool done"?

Fam

Reply via email to