From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 1/2 V2] kvm tools: Add scatter-gather variants of IO functions Date: Sun, 17 Apr 2011 13:22:18 +0300 Message-ID: <1303035738.3017.5.camel@stimpy> References: <1302966356-13145-1-git-send-email-levinsasha928@gmail.com> <4DA9E285.5040308@openvz.org> <4DAAB0A3.3020206@redhat.com> <4DAABAF2.1020700@parallels.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Avi Kivity , "penberg@kernel.org" , "mingo@elte.hu" , "asias.hejun@gmail.com" , "gorcunov@gmail.com" , "kvm@vger.kernel.org" To: Konstantin Khlebnikov Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:44509 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752453Ab1DQKWc (ORCPT ); Sun, 17 Apr 2011 06:22:32 -0400 Received: by wwa36 with SMTP id 36so4618210wwa.1 for ; Sun, 17 Apr 2011 03:22:31 -0700 (PDT) In-Reply-To: <4DAABAF2.1020700@parallels.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, 2011-04-17 at 14:03 +0400, Konstantin Khlebnikov wrote: > Avi Kivity wrote: > > What if nr is nonzero when the loop terminates? You need to update the > > first iovec entry so you don't redo that segment. > > Oh yes, it is simple (hunk above), so "const" from prototype must be removed, > while original syscalls declare iov argument as const. The problem here is that if we start changing the internals of the iovec struct it forces us to copy it before calling the I/O functions since if we change it within the functions it's unusable to the caller anymore. Currently it's passed as a const because we only move pointers outside the struct. Basically the trade-off here is copying iovec before every read/write vs having to sometimes read data again (< 1 block), so I've went with the latter. Do you think it's better to go with the first alternative? -- Sasha.