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

Re: [libvirt] [PATCH 7/8] save: add virDirectFd wrapper type

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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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