From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@cs.helsinki.fi
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
gorcunov@gmail.com, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH v2 09/10] kvm tools: Add aio read write functions
Date: Tue, 1 Nov 2011 18:06:18 +0200 [thread overview]
Message-ID: <1320163579-13811-9-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1320163579-13811-1-git-send-email-levinsasha928@gmail.com>
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 <levinsasha928@gmail.com>
---
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 <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
+#include <libaio.h>
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
next prev parent reply other threads:[~2011-11-01 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-01 16:06 [PATCH v2 01/10] kvm tools: Switch to using an enum for disk image types Sasha Levin
2011-11-01 16:06 ` [PATCH v2 02/10] kvm tools: Remove the non-iov interface from disk image ops Sasha Levin
2011-11-01 16:06 ` [PATCH v2 03/10] kvm tools: Modify disk ops usage Sasha Levin
2011-11-01 16:06 ` [PATCH v2 04/10] kvm tools: Modify behaviour on missing ops ptr Sasha Levin
2011-11-01 16:06 ` [PATCH v2 05/10] kvm tools: Add optional callback on disk op completion Sasha Levin
2011-11-01 16:06 ` [PATCH v2 06/10] kvm tools: Remove qcow nowrite function Sasha Levin
2011-11-01 16:06 ` [PATCH v2 07/10] kvm tools: Split io request from completion Sasha Levin
2011-11-01 16:06 ` [PATCH v2 08/10] kvm tools: Hook virtio-blk completion to disk op completion Sasha Levin
2011-11-01 16:06 ` Sasha Levin [this message]
2011-11-01 16:06 ` [PATCH v2 10/10] kvm tools: Use native vectored AIO in virtio-blk Sasha Levin
2011-11-01 17:07 ` Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1320163579-13811-9-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@cs.helsinki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox