qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 4/9] linux-aio: Implement .cancel_async


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC PATCH 4/9] linux-aio: Implement .cancel_async
Date: Thu, 21 Aug 2014 17:31:06 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

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.

Attachment: pgpd3nIjuxpfy.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]