Il 22/11/2012 11:38, Michael S. Tsirkin ha scritto:
>> > The code is a little simpler, because we know the footer is 1 byte only.
>
> Yes but the APIs don't make sense in the generic case
> of >1 byte: users will have to code up two paths for when
> the buffer they want to access gets scattered across.

That would be premature optimization; with >1 byte you just use
iov_from/to_buf.

BTW, something like this function is also useful for the broken SCSI
outhdr ("the CDB starts after the common outhdr and is in a single
iovec").  But the API must be changed slightly, as in my answer to Stefan.

> If the point is to avoid scanning iov vector when data is towards the
> end of the iov, then this does sound reasonable.  In that case IMHO we
> should just have accessors that work back from end of the iov. E.g.
> 
> size_t iov_from_buf_end(const struct iovec *iov, unsigned int iov_cnt,
>                       size_t offset, const void *buf, size_t bytes)

That's also a possibility.

Paolo


Reply via email to