Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Sasha Levin <levinsasha928@gmail.com>,
	"penberg@kernel.org" <penberg@kernel.org>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"asias.hejun@gmail.com" <asias.hejun@gmail.com>,
	"gorcunov@gmail.com" <gorcunov@gmail.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 1/2 V2] kvm tools: Add scatter-gather variants of IO functions
Date: Sun, 17 Apr 2011 12:19:31 +0300	[thread overview]
Message-ID: <4DAAB0A3.3020206@redhat.com> (raw)
In-Reply-To: <4DA9E285.5040308@openvz.org>

On 04/16/2011 09:40 PM, Konstantin Khlebnikov wrote:
>
> It might be better to add an helper function, something like this:
>
> static inline void shift_iovec(const struct iovec **iov, int *iovcnt,
>                    size_t nr, ssize_t *total, off_t *offset)
> {
>     while (nr >= (*iov)->iov_len) {
>         nr -= (*iov)->iov_len;
>         *total += (*iov)->iov_len;
>         *offset += (*iov)->iov_len;
>         *iovcnt--;
>         *iov++;
>     }
> }
>

What if nr is nonzero when the loop terminates?  You need to update the 
first iovec entry so you don't redo that segment.

> ssize_t pwritev_in_full(int fd, const struct iovec *iov, int iovcnt, 
> off_t offset)
> {
>     ssize_t nr, total = 0;
>
>     while (iovcnt) {
>         nr = xpwritev(fd, iov, iovcnt, offset);
>         if (nr < 0)
>             return -1;
>         if (nr == 0) {
>             errno = ENOSPC;
>             return -1;
>         }
>         shift_iovec(&iov, &iovcnt, nr, &total, &offset);
>     }
>
>     return total;
> }
> -- 
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
error compiling committee.c: too many arguments to function


  parent reply	other threads:[~2011-04-17  9:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16 15:05 [PATCH 1/2 V2] kvm tools: Add scatter-gather variants of IO functions Sasha Levin
2011-04-16 15:05 ` [PATCH 2/2 V2] kvm tools: Add scatter-gather support for disk images Sasha Levin
2011-04-16 18:40 ` [PATCH 1/2 V2] kvm tools: Add scatter-gather variants of IO functions Konstantin Khlebnikov
2011-04-16 20:33   ` Sasha Levin
2011-04-17  9:19   ` Avi Kivity [this message]
2011-04-17 10:03     ` Konstantin Khlebnikov
2011-04-17 10:22       ` Sasha Levin
2011-04-17 10:34         ` Konstantin Khlebnikov
2011-04-17 11:11           ` Sasha Levin
2011-04-17 12:49             ` 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=4DAAB0A3.3020206@redhat.com \
    --to=avi@redhat.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=khlebnikov@openvz.org \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    /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