[libvirt] [PATCH 7/8] save: add virDirectFd wrapper type
Eric Blake
eblake at redhat.com
Thu Jul 14 14:34:46 UTC 2011
On 07/14/2011 08:24 AM, Eric Blake wrote:
> O_DIRECT has stringent requirements - I/O must occur with buffers
> that have both alignment and size as multiples of the file system
> block size (used to be 512 bytes, but these days, 4k is safer, and
> 64k allows for better throughput). Rather than make lots of changes
> at each site that wants to use O_DIRECT, it is easier to offload
> the work through a helper process that mirrors the I/O between a
> pipe and the actual direct fd, so that the other end of the pipe
> no longer has to worry about constraints.
>
> +virDirectFdPtr
> +virDirectFdNew(int *fd, const char *name)
> +{
> + virDirectFdPtr ret = NULL;
> + bool output = false;
> + int pipefd[2] = { -1, -1 };
> + int mode = -1;
> +
> + if (VIR_ALLOC(ret) < 0) {
> + virReportOOMError();
> + goto error;
> + }
> + if (!O_DIRECT)
> + return ret;
Question - should an attempt to use 'virsh save --direct' on a system
that lacks O_DIRECT (think mingw) be rejected, rather than silently
ignored? My argument is that --direct is merely an optimization hint -
it tries to reduce filesystem cache pollution (possibly at the expense
of slower operation), but other than the cache effects, the end result
is the same as if O_DIRECT is unavailable. Hence, my decision of
silently ignoring it rather than erroring out.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110714/71d19baa/attachment-0001.sig>
More information about the libvir-list
mailing list