From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2] tools/libxc: Implement writev_exact() in the same style as write_exact() Date: Tue, 8 Jul 2014 18:00:25 +0100 Message-ID: <53BC23A9.8000808@citrix.com> References: <1404728318-13474-1-git-send-email-andrew.cooper3@citrix.com> <53BBB966.4020609@citrix.com> <53BBBA9C.1030005@citrix.com> <21436.9020.757598.972931@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21436.9020.757598.972931@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Ian Campbell , David Vrabel , Xen-devel List-Id: xen-devel@lists.xenproject.org On 08/07/14 17:58, Ian Jackson wrote: > 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: > http://pubs.opengroup.org/onlinepubs/9699919799/functions/writev.html > http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html > etc. > > 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: > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_07 > > 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. > > Ian. Ok - in which case v1 of the patch is correct. I shall submit v3 which looks similar to v1, but with some comments improvements ~Andrew