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

Re: [Xen-devel] [PATCH v2] tools/libxc: Implement writev_exact() in the same style as write_exact()

Andrew Cooper writes ("Re: [Xen-devel] [PATCH v2] tools/libxc: Implement 
writev_exact() in the same style as write_exact()"):
> Final paragraph in the DESCRIPTION
> "The data transfers performed by readv() and writev() are atomic: the
> data written by writev() is written as a single block that is not
> intermingled with output from writes in other processes"
> By my reading, it cannot guarantee atomicity if it would split an iov[]
> element.

Firstly, we should be using the spec, not manpages:

There are various guarantees that write and writev provide, including
the special rule for pipes (from write.html):

  Write requests to a pipe or FIFO shall be handled in the same way as
  a regular file with the following exceptions:
     [ complicated rules involving PIPE_BUF ]

and the general rule about system call atomicity:


 All of the following functions shall be atomic with respect to each
 other in the effects specified in POSIX.1-2008 when they operate on
 regular files or symbolic links:
    [...] write() writev() [...]

However neither of these are the guarantee that you are assuming.

In particular, there is nothing saying that _if_ writev performs a
partial write, it won't stop inside an iov.


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.