Re: [RFC] writev() semantics with invalid iovec in the middle

From: Linus Torvalds
Date: Fri Sep 16 2016 - 14:37:05 EST


On Fri, Sep 16, 2016 at 6:25 AM, One Thousand Gnomes
<gnomes@xxxxxxxxxxxxxxxxxxx> wrote:
>
> 1003.1 says
>
> "Each iovec entry specifies the base address and length of an area in
> memory from which data should be written. The writev() function shall
> always write a complete area before proceeding to the next."
>
> and I imagine that is what LTP is attempting to test.

Ahh. Yes. But as you note, the EFAULT case is undefined behavior, so
what that POSIX language is *really* about is presumably making sure
that readers of a file cannot see the "later" writes without seeing
the earlier ones.

So you cannot do some fancy threaded thing where you do different
iovec parts concurrently, because that could be seen by a reader (or
more likely mmap) as doing the writes out of order.

Or, as you mention, the disk-full case.

Linus