On Thu, 08/21 17:31, Stefan Hajnoczi wrote:
> On Thu, Aug 21, 2014 at 07:56:51PM +0800, Fam Zheng wrote:
> > @@ -110,6 +109,22 @@ static void qemu_laio_completion_cb(EventNotifier *e)
> >      }
> >  }
> >  
> > +static void laio_cancel_async(BlockDriverAIOCB *blockacb)
> > +{
> > +    struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb;
> > +    struct io_event event;
> > +    int ret;
> > +
> > +    ret = io_cancel(laiocb->ctx->ctx, &laiocb->iocb, &event);
> > +    laiocb->ret = -ECANCELED;
> > +    if (!ret) {
> > +        /* iocb is not cancelled, cb will be called by the event loop 
> > later */
> > +        return;
> > +    }
> 
> No callback will be invoked if io_cancel(2) every cancels the request
> immediately.
> 
> The current kernel implementation always returns -EINPROGRESS or some of
> other error value.  But some day it might return 0 and this would leak
> the request!
> 
> > +
> > +    laiocb->common.cb(laiocb->common.opaque, laiocb->ret);
> > +}
> 
> It would be cleaner to reuse laio_cancel_async() from laio_cancel() to
> avoid code duplication.  For example, there is a useful comment in
> laio_cancel() explaining that io_cancel(2) doesn't cancel I/O in
> practice on 2.6.31 era kernels.

I'll take a closer look at it.

Fam

Reply via email to