[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 28/29] posix-aio-compat: Allow read after EOF
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 28/29] posix-aio-compat: Allow read after EOF |
Date: |
Wed, 3 Aug 2011 16:14:23 +0200 |
In order to be able to transparently replace bdrv_read calls by bdrv_co_read,
reading beyond EOF must produce zeros instead of short reads for AIO, too.
Signed-off-by: Kevin Wolf <address@hidden>
---
posix-aio-compat.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 788d113..8dc00cb 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -198,6 +198,12 @@ static ssize_t handle_aiocb_rw_vector(struct qemu_paiocb
*aiocb)
return len;
}
+/*
+ * Read/writes the data to/from a given linear buffer.
+ *
+ * Returns the number of bytes handles or -errno in case of an error. Short
+ * reads are only returned if the end of the file is reached.
+ */
static ssize_t handle_aiocb_rw_linear(struct qemu_paiocb *aiocb, char *buf)
{
ssize_t offset = 0;
@@ -334,6 +340,19 @@ static void *aio_thread(void *unused)
switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) {
case QEMU_AIO_READ:
+ ret = handle_aiocb_rw(aiocb);
+ if (ret >= 0 && ret < aiocb->aio_nbytes &&
aiocb->common.bs->growable) {
+ /* A short read means that we have reached EOF. Pad the buffer
+ * with zeros for bytes after EOF. */
+ QEMUIOVector qiov;
+
+ qemu_iovec_init_external(&qiov, aiocb->aio_iov,
+ aiocb->aio_niov);
+ qemu_iovec_memset_skip(&qiov, 0, aiocb->aio_nbytes - ret, ret);
+
+ ret = aiocb->aio_nbytes;
+ }
+ break;
case QEMU_AIO_WRITE:
ret = handle_aiocb_rw(aiocb);
break;
--
1.7.6
- [Qemu-devel] [PATCH 14/29] raw-posix: Typo fix, (continued)
- [Qemu-devel] [PATCH 14/29] raw-posix: Typo fix, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 10/29] scsi: Remove REZERO_UNIT emulation, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 15/29] raw-posix: Always check paio_init result, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 18/29] coroutine: add test-coroutine automated tests, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 16/29] coroutine: introduce coroutines, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 22/29] block: Add bdrv_co_readv/writev emulation, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 19/29] coroutine: add test-coroutine --benchmark-lifecycle, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 20/29] block: Add bdrv_co_readv/writev, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 21/29] block: Emulate AIO functions with bdrv_co_readv/writev, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 29/29] block: Use bdrv_co_* instead of synchronous versions in coroutines, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 28/29] posix-aio-compat: Allow read after EOF,
Kevin Wolf <=
- [Qemu-devel] [PATCH 23/29] coroutines: Locks, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 17/29] coroutine: implement coroutines using gthread, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 25/29] qcow: Use coroutines, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 26/29] async: Remove AsyncContext, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 27/29] coroutines: Use one global bottom half for CoQueue, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 24/29] qcow2: Use coroutines, Kevin Wolf, 2011/08/03
- Re: [Qemu-devel] [PULL 00/29] Block patches, Anthony Liguori, 2011/08/04