From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKgtH-0001zM-Lr for qemu-devel@nongnu.org; Fri, 22 Aug 2014 00:56:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKgtB-0007vU-Ho for qemu-devel@nongnu.org; Fri, 22 Aug 2014 00:55:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKgtB-0007vE-AS for qemu-devel@nongnu.org; Fri, 22 Aug 2014 00:55:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7M4tmsI008859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 22 Aug 2014 00:55:48 -0400 Date: Fri, 22 Aug 2014 12:56:00 +0800 From: Fam Zheng Message-ID: <20140822045600.GE3410@T430.redhat.com> References: <1408622216-9578-1-git-send-email-famz@redhat.com> <1408622216-9578-5-git-send-email-famz@redhat.com> <20140821163106.GD22844@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140821163106.GD22844@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [RFC PATCH 4/9] linux-aio: Implement .cancel_async List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org 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