From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QliUJ-0004EN-6b for qemu-devel@nongnu.org; Tue, 26 Jul 2011 10:20:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QliUI-0002G9-7s for qemu-devel@nongnu.org; Tue, 26 Jul 2011 10:19:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QliUH-0002Fv-Vt for qemu-devel@nongnu.org; Tue, 26 Jul 2011 10:19:58 -0400 Message-ID: <4E2ECDBC.3020502@redhat.com> Date: Tue, 26 Jul 2011 16:22:52 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1311680948-7648-1-git-send-email-kwolf@redhat.com> <1311680948-7648-10-git-send-email-kwolf@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 09/10] posix-aio-compat: Allow read after EOF List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Frediano Ziglio Cc: stefanha@gmail.com, qemu-devel@nongnu.org Am 26.07.2011 15:55, schrieb Frediano Ziglio: > 2011/7/26 Kevin Wolf : >> 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 >> --- >> 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