From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqjQZ-0004lX-GP for qemu-devel@nongnu.org; Tue, 18 Nov 2014 09:06:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqjQS-0001ZX-QO for qemu-devel@nongnu.org; Tue, 18 Nov 2014 09:06:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqjQS-0001ZN-Ir for qemu-devel@nongnu.org; Tue, 18 Nov 2014 09:06:36 -0500 Message-ID: <546B525F.3070001@redhat.com> Date: Tue, 18 Nov 2014 15:06:23 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1415286601-30715-1-git-send-email-ming.lei@canonical.com> <1415286601-30715-3-git-send-email-ming.lei@canonical.com> In-Reply-To: <1415286601-30715-3-git-send-email-ming.lei@canonical.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 2/3] linux-aio: handling -EAGAIN for !s->io_q.plugged case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei , qemu-devel@nongnu.org, Peter Maydell , Stefan Hajnoczi , Kevin Wolf Cc: =?windows-1252?Q?Beno=EEt_Canet?= On 06/11/2014 16:10, Ming Lei wrote: > + /* don't submit until next completion for -EAGAIN of non plug case */ > + if (unlikely(!s->io_q.plugged)) { > + return 0; > + } > + Is this an optimization or a fix for something? > + /* > + * Switch to queue mode until -EAGAIN is handled, we suppose > + * there is always uncompleted I/O, so try to enqueue it first, > + * and will be submitted again in following aio completion cb. > + */ > + if (ret == -EAGAIN) { > + goto enqueue; > + } else if (ret < 0) { > goto out_free_aiocb; > } Better: if (!s->io_q.plugged && !s->io_q.idx) { ret = io_submit(s->ctx, 1, &iocbs); if (ret >= 0) { return &laiocb->common; } if (ret != -EAGAIN) { goto out_free_aiocb; } } /* code for queue mode. */ Paolo