Patchwork [1/2] win32-aio: Fix vectored reads

login
register
mail settings
Submitter Kevin Wolf
Date Jan. 16, 2013, 8:19 p.m.
Message ID <1358367600-8074-2-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/213057/
State New
Headers show

Comments

Kevin Wolf - Jan. 16, 2013, 8:19 p.m.
Copying data in the right direction really helps a lot!

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/win32-aio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Michael Tokarev - Jan. 17, 2013, 8:33 a.m.
17.01.2013 00:19, Kevin Wolf пишет:
> Copying data in the right direction really helps a lot!
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/win32-aio.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/block/win32-aio.c b/block/win32-aio.c
> index 46a5db7..53b82e6 100644
> --- a/block/win32-aio.c
> +++ b/block/win32-aio.c
> @@ -84,7 +84,7 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
>               int i;
>
>               for (i = 0; i < qiov->niov; ++i) {
> -                memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
> +                memcpy(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
>                   p += qiov->iov[i].iov_len;
>               }
>               g_free(waiocb->buf);

Actually this is just

    iov_from_buf(qiov->iov, qiov->niov, 0, waiocb->buf, -1);

Or is it iov_to_buf() ? :)

Thanks,

/mjt
Kevin Wolf - Jan. 17, 2013, 8:43 a.m.
Am 17.01.2013 09:33, schrieb Michael Tokarev:
> 17.01.2013 00:19, Kevin Wolf пишет:
>> Copying data in the right direction really helps a lot!
>>
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>>   block/win32-aio.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/block/win32-aio.c b/block/win32-aio.c
>> index 46a5db7..53b82e6 100644
>> --- a/block/win32-aio.c
>> +++ b/block/win32-aio.c
>> @@ -84,7 +84,7 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
>>               int i;
>>
>>               for (i = 0; i < qiov->niov; ++i) {
>> -                memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
>> +                memcpy(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
>>                   p += qiov->iov[i].iov_len;
>>               }
>>               g_free(waiocb->buf);
> 
> Actually this is just
> 
>     iov_from_buf(qiov->iov, qiov->niov, 0, waiocb->buf, -1);

True. Let's keep fix and cleanup separate, though. Feel free to send a
cleanup patch on top of this.

By the way, I think qiov->size instead of -1 would be nicer.

> Or is it iov_to_buf() ? :)

The corrected version is from.

Kevin

Patch

diff --git a/block/win32-aio.c b/block/win32-aio.c
index 46a5db7..53b82e6 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -84,7 +84,7 @@  static void win32_aio_process_completion(QEMUWin32AIOState *s,
             int i;
 
             for (i = 0; i < qiov->niov; ++i) {
-                memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
+                memcpy(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
                 p += qiov->iov[i].iov_len;
             }
             g_free(waiocb->buf);