From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyonW-00084x-Ab for qemu-devel@nongnu.org; Wed, 21 May 2008 09:56:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyonU-000827-RX for qemu-devel@nongnu.org; Wed, 21 May 2008 09:56:05 -0400 Received: from [199.232.76.173] (port=36786 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyonU-00081h-Bj for qemu-devel@nongnu.org; Wed, 21 May 2008 09:56:04 -0400 Received: from py-out-1112.google.com ([64.233.166.180]:58447) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JyonU-0007I8-5z for qemu-devel@nongnu.org; Wed, 21 May 2008 09:56:04 -0400 Received: by py-out-1112.google.com with SMTP id p76so164925pyb.10 for ; Wed, 21 May 2008 06:56:03 -0700 (PDT) Message-ID: <483429EB.7070705@codemonkey.ws> Date: Wed, 21 May 2008 08:55:55 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH][v2] Align file accesses with cache=off (O_DIRECT) References: <1211283126.4314.70.camel@frecb07144> <200805202352.17807.paul@codesourcery.com> <483373BA.6090108@codemonkey.ws> <200805210205.37432.paul@codesourcery.com> <4833778C.4030209@codemonkey.ws> <4833DC3F.8000604@suse.de> <20080521122629.GA14416@shareable.org> <48341783.3060204@qumranet.com> <20080521134154.GA15210@shareable.org> In-Reply-To: <20080521134154.GA15210@shareable.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Laurent Vivier , Paul Brook 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 > > > >