From: Kevin Wolf <kwolf@redhat.com>
To: Frediano Ziglio <freddy77@gmail.com>
Cc: stefanha@gmail.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 09/10] posix-aio-compat: Allow read after EOF
Date: Tue, 26 Jul 2011 16:22:52 +0200 [thread overview]
Message-ID: <4E2ECDBC.3020502@redhat.com> (raw)
In-Reply-To: <CAHt6W4cgKOP4C7s0VrNFx19B2z42+vRDn8_GAOsbJfMPrx8Tgw@mail.gmail.com>
Am 26.07.2011 15:55, schrieb Frediano Ziglio:
> 2011/7/26 Kevin Wolf <kwolf@redhat.com>:
>> 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 <kwolf@redhat.com>
>> ---
>> 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
>>
>
> Still not tested but I think to know what does it solve :)
>
> I think Linux AIO require same attention.
In theory yes, but it's not as easy and for some reason I couldn't
reproduce it with Linux AIO (maybe the problematic requests are
misaligned so that it falls back to posix-aio-compat.c), so I decided to
ignore it for now.
Patches are welcome. ;-)
Kevin
next prev parent reply other threads:[~2011-07-26 14:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-26 11:48 [Qemu-devel] [PATCH 00/10] block: Coroutine support Kevin Wolf
2011-07-26 11:48 ` [Qemu-devel] [PATCH 01/10] block: Add bdrv_co_readv/writev Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 02/10] block: Emulate AIO functions with bdrv_co_readv/writev Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 03/10] block: Add bdrv_co_readv/writev emulation Kevin Wolf
2011-08-02 12:12 ` Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 04/10] coroutines: Locks Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 05/10] qcow2: Use coroutines Kevin Wolf
2011-07-29 13:20 ` Stefan Hajnoczi
2011-07-26 11:49 ` [Qemu-devel] [PATCH 06/10] qcow: " Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 07/10] async: Remove AsyncContext Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 08/10] coroutines: Use one global bottom half for CoQueue Kevin Wolf
2011-07-26 11:49 ` [Qemu-devel] [PATCH 09/10] posix-aio-compat: Allow read after EOF Kevin Wolf
2011-07-26 13:55 ` Frediano Ziglio
2011-07-26 14:22 ` Kevin Wolf [this message]
2011-07-26 11:49 ` [Qemu-devel] [PATCH 10/10] block: Use bdrv_co_* instead of synchronous versions in coroutines Kevin Wolf
2011-08-02 13:56 ` [Qemu-devel] [PATCH v2 " Kevin Wolf
2011-08-01 9:59 ` [Qemu-devel] [PATCH 00/10] block: Coroutine support Stefan Hajnoczi
2011-08-02 14:23 ` Avi Kivity
2011-08-02 14:50 ` Kevin Wolf
2011-08-02 14:55 ` Frediano Ziglio
2011-08-02 15:14 ` Kevin Wolf
2011-08-02 14:58 ` Anthony Liguori
2011-08-02 14:59 ` Avi Kivity
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=4E2ECDBC.3020502@redhat.com \
--to=kwolf@redhat.com \
--cc=freddy77@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.