Re: [PATCH 1/2 V2] kvm tools: Add scatter-gather variants of IO functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2011-04-16 at 22:40 +0400, 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++;
> 	}
> }
> 
> 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;
> }

Yup, Good idea - Let's do that.

Thanks!

-- 

Sasha.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux