qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Re: [PATCH][v2] Align file accesses with cache=off (O_D


From: Anthony Liguori
Subject: Re: [Qemu-devel] Re: [PATCH][v2] Align file accesses with cache=off (O_DIRECT)
Date: Wed, 21 May 2008 08:55:55 -0500
User-agent: Thunderbird 2.0.0.14 (X11/20080501)

Jamie Lokier wrote:
Avi Kivity wrote:
Jamie Lokier wrote:
Why would O_SYNC be better than O_DIRECT?
O_SYNC is a write-through cache. O_DIRECT is completely uncached. Both have their uses (including in this context), so you can't say one is better than the other.

Fine, but the question is: why would O_SYNC be better for
*data integrity* than O_DIRECT?  Referring to:

"cached" is not a terribly accurate term. O_DIRECT avoids the host page cache but it doesn't guarantee that the disk is using write-through. For that, you need to use hdparm.

O_SYNC basically turns the host page cache into a write-through cache. In terms of data integrity, the only question that matters is whether you're misleading the guest into thinking data is on the disk when it isn't. Both O_DIRECT and O_SYNC accomplish this.

If you just are concerned with data integrity, O_SYNC is probably better because you get the benefits of host caching. O_DIRECT is really for circumstances where you know that using the host page cache is going to reduce performance.

Regards,

Anthony Liguori

Anthony Liguori wrote:
For people that care about data integrity, we should be using O_SYNC,
not O_DIRECT anyway.

Could it be connected with this, from elsewhere?

Rob van Nieuwkerk wrote:
It appears that somewhere between RH kernels 2.4.18-27.7.x and 2.4.20-18.9
something has changed so that my application needs a O_SYNC too besides
the O_DIRECT to make sure that writes will be synchronous.  If I leave
the O_SYNC out with 2.4.20-18.9 the write will happen physically 35
seconds after the write()

For that, O_SYNC is used in conjunction with O_DIRECT, rather than
instead of it.

-- Jamie








reply via email to

[Prev in Thread] Current Thread [Next in Thread]