From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH v2 09/10] kvm tools: Add aio read write functions Date: Tue, 1 Nov 2011 18:06:18 +0200 Message-ID: <1320163579-13811-9-git-send-email-levinsasha928@gmail.com> References: <1320163579-13811-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@cs.helsinki.fi Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:50583 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932227Ab1KAQI0 (ORCPT ); Tue, 1 Nov 2011 12:08:26 -0400 Received: by mail-ey0-f174.google.com with SMTP id 27so6345771eye.19 for ; Tue, 01 Nov 2011 09:08:25 -0700 (PDT) In-Reply-To: <1320163579-13811-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: This patch adds basic native vectored AIO functions. These functions should be optimized to process multiple io requests at once. Signed-off-by: Sasha Levin --- tools/kvm/Makefile | 1 + tools/kvm/include/kvm/read-write.h | 6 ++++++ tools/kvm/read-write.c | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 0 deletions(-) diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index d9baa69..6095440 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -124,6 +124,7 @@ OBJS += bios/bios-rom.o LIBS += -lrt LIBS += -lpthread LIBS += -lutil +LIBS += -laio # Additional ARCH settings for x86 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ diff --git a/tools/kvm/include/kvm/read-write.h b/tools/kvm/include/kvm/read-write.h index 3351103..89c1590 100644 --- a/tools/kvm/include/kvm/read-write.h +++ b/tools/kvm/include/kvm/read-write.h @@ -4,6 +4,7 @@ #include #include #include +#include ssize_t xread(int fd, void *buf, size_t count); ssize_t xwrite(int fd, const void *buf, size_t count); @@ -29,4 +30,9 @@ ssize_t xpwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset); ssize_t preadv_in_full(int fd, const struct iovec *iov, int iovcnt, off_t offset); ssize_t pwritev_in_full(int fd, const struct iovec *iov, int iovcnt, off_t offset); +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); +int aio_pwritev(io_context_t ctx, struct iocb *iocb, int fd, const struct iovec *iov, int iovcnt, + off_t offset, int ev, void *param); + #endif /* KVM_READ_WRITE_H */ diff --git a/tools/kvm/read-write.c b/tools/kvm/read-write.c index 737fb26..be5a4fa 100644 --- a/tools/kvm/read-write.c +++ b/tools/kvm/read-write.c @@ -316,3 +316,27 @@ ssize_t pwritev_in_full(int fd, const struct iovec *iov, int iovcnt, off_t offse return total; } + +int aio_pwritev(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 }; + + io_prep_pwritev(iocb, fd, iov, iovcnt, offset); + io_set_eventfd(iocb, ev); + iocb->data = param; + + return io_submit(ctx, 1, ios); +} + +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 }; + + io_prep_preadv(iocb, fd, iov, iovcnt, offset); + io_set_eventfd(iocb, ev); + iocb->data = param; + + return io_submit(ctx, 1, ios); +} -- 1.7.7.1