From: Asias He Subject: [PATCH 2/2] kvm tools: Restart io_submit if it returns EAGAIN Date: Mon, 4 Jun 2012 23:10:05 +0800 Message-ID: <1338822605-23140-2-git-send-email-asias.hejun@gmail.com> References: <1338822605-23140-1-git-send-email-asias.hejun@gmail.com> Cc: Sasha Levin , Ingo Molnar , Cyrill Gorcunov , kvm@vger.kernel.org, Asias He To: Pekka Enberg Return-path: Received: from mail-pz0-f46.google.com ([209.85.210.46]:51224 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760748Ab2FDPJj (ORCPT ); Mon, 4 Jun 2012 11:09:39 -0400 Received: by dady13 with SMTP id y13so5946954dad.19 for ; Mon, 04 Jun 2012 08:09:38 -0700 (PDT) In-Reply-To: <1338822605-23140-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Keep trying if io_submit returns EAGAIN. No need to fail the request. Signed-off-by: Asias He --- tools/kvm/util/read-write.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/kvm/util/read-write.c b/tools/kvm/util/read-write.c index 55473ba..44709df 100644 --- a/tools/kvm/util/read-write.c +++ b/tools/kvm/util/read-write.c @@ -322,23 +322,33 @@ int aio_pwritev(io_context_t ctx, struct iocb *iocb, int fd, const struct iovec off_t offset, int ev, void *param) { struct iocb *ios[1] = { iocb }; + int ret; io_prep_pwritev(iocb, fd, iov, iovcnt, offset); io_set_eventfd(iocb, ev); iocb->data = param; - return io_submit(ctx, 1, ios); +restart: + ret = io_submit(ctx, 1, ios); + if (ret == -EAGAIN) + goto restart; + return ret; } int aio_preadv(io_context_t ctx, struct iocb *iocb, int fd, const struct iovec *iov, int iovcnt, off_t offset, int ev, void *param) { struct iocb *ios[1] = { iocb }; + int ret; io_prep_preadv(iocb, fd, iov, iovcnt, offset); io_set_eventfd(iocb, ev); iocb->data = param; - return io_submit(ctx, 1, ios); +restart: + ret = io_submit(ctx, 1, ios); + if (ret == -EAGAIN) + goto restart; + return ret; } -#endif \ No newline at end of file +#endif -- 1.7.10.2