From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MiFAs-000191-7e for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:16:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MiFAn-00011B-AM for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:16:29 -0400 Received: from [199.232.76.173] (port=59004 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MiFAn-00010v-2o for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:16:25 -0400 Received: from verein.lst.de ([213.95.11.210]:34922) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1MiFAm-0004Ma-Lg for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:16:24 -0400 Date: Tue, 1 Sep 2009 00:16:22 +0200 From: Christoph Hellwig Subject: Re: [Qemu-devel] [PATCH 1/4] block: add enable_write_cache flag Message-ID: <20090831221622.GA8834@lst.de> References: <20090831201627.GA4811@lst.de> <20090831201651.GA4874@lst.de> <20090831220950.GB24318@shareable.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090831220950.GB24318@shareable.org> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: Christoph Hellwig , qemu-devel@nongnu.org On Mon, Aug 31, 2009 at 11:09:50PM +0100, Jamie Lokier wrote: > Right now, on a Linux host O_SYNC is unsafe with hardware that has a > volatile write cache. That might not be changed, but if it is than > performance with cache=writethrough will plummet (due to issuing a > CACHE FLUSH to the hardware after every write), while performance with > cache=writeback will be reasonable. Currenly all modes are more or less unsafe with volatile write caches at least when using ext3 or raw block device accesses. XFS is safe two thirds due to doing the right thing and one third due to sheer luck. > If an unsafe mode is desired (I think it is, for those throwaway > testing VMs, or during OS installs), I suggest adding cache=volatile: > > cache=none > O_DIRECT, fdatasync, advertise volatile write cache > > cache=writethrough > O_SYNC, do not advertise > > cache=writeback > fdatasync, advertise volatile write cache > > cache=volatile > nothing (perhaps fdatasync on QEMU blockdev close) Fine withe me, let the flame war begin :) > When using guests OSes which issue CACHE FLUSH commands (that's a > guest config issue), why would you ever use cache=writethrough? > cache=writeback should be faster and equally safe - provided you do > actually advertise the write cache! And provided the guest OS actually issues cache flushes when it should, something that at least Linux historicaly utterly failed at, and some other operating systems haven't even tried. cache=writethrough is the equivalent of turning off the volatile write cache of the real disk. It might be slower (which isn't even always the case for real disks), but it is much safer. E.g. if you want to move your old SCO Unix box into a VM it's the only safe option.