From: Andrew Cooper <andrew.cooper3@citrix.com>
To: David Vrabel <david.vrabel@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH v2] tools/libxc: Implement writev_exact() in the same style as write_exact()
Date: Tue, 8 Jul 2014 10:32:12 +0100 [thread overview]
Message-ID: <53BBBA9C.1030005@citrix.com> (raw)
In-Reply-To: <53BBB966.4020609@citrix.com>
On 08/07/14 10:27, David Vrabel wrote:
> On 07/07/14 11:18, Andrew Cooper wrote:
>> This implementation of writev_exact() will cope with an iovcnt greater than
>> IOV_MAX because glibc will actually let this work anyway, and it is very
>> useful not to have to work about this in the caller of writev_exact(). The
>> caller is still required to ensure that the sum of iov_len's doesn't overflow
>> a ssize_t.
>>
>> Promote the MAX() and MIN() macro definitions from xg_save_restore.h to
>> xc_private.h
> [...]
>> --- a/tools/libxc/xc_private.c
>> +++ b/tools/libxc/xc_private.c
>> @@ -854,6 +854,37 @@ int write_exact(int fd, const void *data, size_t size)
>> return 0;
>> }
>>
>> +int writev_exact(int fd, const struct iovec *iov, int iovcnt)
>> +{
> [...]
>> + /* writev() guarentees atomicity of individual iov[] elements. Sanity
>> + * check that the returned len did lie on an iov[] element boundary. */
>> + assert(len == 0);
> There's nothing in the writev(2) man page that says this. I think you
> need to handle partial writes of an entry.
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.
>
>> --- a/tools/libxc/xc_private.h
>> +++ b/tools/libxc/xc_private.h
> [...]
>> +#ifndef MAX
>> +#define MAX(_a, _b) ((_a) >= (_b) ? (_a) : (_b))
>> +#endif
>> +#ifndef MIN
>> +#define MIN(_a, _b) ((_a) <= (_b) ? (_a) : (_b))
>> +#endif
> Do we really want to use these unsafe macros in more places?
>
> David
Perhaphs, perhaps not, but there are no typesafe ones to hand.
~Andrew
next prev parent reply other threads:[~2014-07-08 9:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 10:18 [PATCH v2] tools/libxc: Implement writev_exact() in the same style as write_exact() Andrew Cooper
2014-07-08 3:30 ` Hongyang Yang
2014-07-08 9:27 ` David Vrabel
2014-07-08 9:32 ` Andrew Cooper [this message]
2014-07-08 16:58 ` Ian Jackson
2014-07-02 18:04 ` [PATCH] " Andrew Cooper
2014-07-03 17:15 ` Ian Jackson
2014-07-03 17:41 ` Andrew Cooper
2014-07-08 17:00 ` [PATCH v2] " Andrew Cooper
2014-07-08 17:10 ` [PATCH] tools/libxc: Implement writev_exact() in the same style as write_exact() [and 1 more messages] Ian Jackson
2014-07-08 16:53 ` [PATCH v2] tools/libxc: Implement writev_exact() in the same style as write_exact() Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53BBBA9C.1030005@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=david.vrabel@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.