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

Eric Blake eblake at redhat.com
Tue Jul 19 16:08:21 UTC 2011

On 07/19/2011 10:06 AM, Daniel P. Berrange wrote:
> The motivation for using O_DIRECT is that allowing pollution of the
> host cache causes stability problems for the host as a whole. As
> such IMHO, apps would likely want an error back if O_DIRECT cannot
> be supported,
> NB, even some Linux filesystems can't do O_DIRECT, so this isn't an
> obscure mingw32 issue.

Conversely, open() on Linux silently ignores unknown flags - so if you 
are using a really old kernel but newer glibc headers, then O_DIRECT is 
non-zero and open() succeeds, but you _don't_ get direct I/O.

If O_DIRECT is 0, then it is pretty easy to diagnose that the request is 
unsupported.  But if O_DIRECT is non-zero, then how do I tell whether 
the open(O_DIRECT) really meant that I have direct I/O, or whether it 
was a nice hint but still ignored and I'm still polluting the file 
system cache?

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

More information about the libvir-list mailing list