From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55530 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OxlSz-00068J-Gx for qemu-devel@nongnu.org; Mon, 20 Sep 2010 14:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OxlSy-0001xQ-1z for qemu-devel@nongnu.org; Mon, 20 Sep 2010 14:51:53 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:59211) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxlSx-0001wO-UZ for qemu-devel@nongnu.org; Mon, 20 Sep 2010 14:51:52 -0400 Received: by ywg4 with SMTP id 4so1864373ywg.4 for ; Mon, 20 Sep 2010 11:51:51 -0700 (PDT) Message-ID: <4C97AD39.9050001@codemonkey.ws> Date: Mon, 20 Sep 2010 13:51:37 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Caching modes References: <4C97916E.2080801@codemonkey.ws> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Kevin Wolf , qemu-devel , Christoph Hellwig On 09/20/2010 01:37 PM, Blue Swirl wrote: > > It would be nice to have additional mode, like cache=always, where > even flushes MAY be ignored. This would max out the performance. > That's cache=unsafe and we have it. I ignored it for the purposes of this discussion. >> Guest disk cache. >> >> For all devices that support it, the exposed cache attribute should be >> independent of the host caching mode. Here are correct usages of disk >> caching mode: >> >> Writethrough disk cache; cache=none|writethrough if the disk cache is set to >> writethrough or the disk is considered "enterprise class" and has a battery >> backup. cache=writeback IFF the host is backed by an UPS. >> > The "enterprise class" disks, battery backups and UPS devices are not > consumer equipment. Wouldn't this mean that any private QEMU user > would need to use cache=none? > No, cache=writethrough and cache=none should be equivalent from a data integrity/data loss perspective. Using cache=writeback without enterprise storage is risky but practically speaking, most consumer storage is not battery backed and uses writeback caching anyway so there is already risk. > As an example, what is the correct usage for laptop user, considering > that there is a battery, but it can also drain and the drainage is > dependent on flush frequency? > Minus cache=unsafe, you'll never get data corruption. The only consideration is how much data loss can occur from the last time there was a flush. Well behaved applications always flush important data to avoid loss of anything important but practically speaking, the world isn't full of behaved applications. The only difference between cache=writeback and a normal disk's writeback cache is that cache=writeback can be a very, very large cache that isn't frequently flushed. So the amount of data loss can be much higher than expected. For most laptop users, cache=none or cache=writethrough is appropriate. For a developer, cache=writeback probably is reasonable. Regards, Anthony Liguori Regards, Anthony Liguori