From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2 V2] kvm tools: Add scatter-gather variants of IO functions Date: Sun, 17 Apr 2011 12:19:31 +0300 Message-ID: <4DAAB0A3.3020206@redhat.com> References: <1302966356-13145-1-git-send-email-levinsasha928@gmail.com> <4DA9E285.5040308@openvz.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Sasha Levin , "penberg@kernel.org" , "mingo@elte.hu" , "asias.hejun@gmail.com" , "gorcunov@gmail.com" , "kvm@vger.kernel.org" To: Konstantin Khlebnikov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60921 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752223Ab1DQJTu (ORCPT ); Sun, 17 Apr 2011 05:19:50 -0400 In-Reply-To: <4DA9E285.5040308@openvz.org> Sender: kvm-owner@vger.kernel.org List-ID: 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