On Tue, Nov 18, 2014 at 10:06 PM, Paolo Bonzini <pbonz...@redhat.com> wrote: > > > 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?
It is for avoiding unnecessary submission which will cause another -EAGAIN. > >> + /* >> + * 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; > } > } Right. Thanks, Ming Lei