Received: from eggs.gnu.org ([208.118.235.92]:33692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtK0n-0002kM-1o for qemu-devel@nongnu.org; Thu, 10 Jan 2013 10:25:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtK0f-0007KJ-VO for qemu-devel@nongnu.org; Thu, 10 Jan 2013 10:25:44 -0500 Received: from [2001:41c8:1:56fc::10] (port=52954 helo=mail2.shareable.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtK0f-0007KE-Pi for qemu-devel@nongnu.org; Thu, 10 Jan 2013 10:25:37 -0500 Date: Thu, 10 Jan 2013 15:25:35 +0000 From: Jamie Lokier Message-ID: <20130110152535.GD21483@jl-vm1.vm.bytemark.co.uk> References: <50EC0D41.4070200@redhat.com> <50EC1C9A.5040006@gmail.com> <50ED45A8.5020706@redhat.com> <50ED4829.1070302@gmail.com> <50ED4933.3040001@redhat.com> <50ED4A90.2080808@gmail.com> <50ED5D64.4040600@gmail.com> <50ED65AA.60000@redhat.com> <50ED6AF4.4060300@gmail.com> <50ED8868.6010805@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50ED8868.6010805@redhat.com> Subject: Re: [Qemu-devel] [PATCH] sheepdog: implement direct write semantics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , Liu Yuan , qemu-devel@nongnu.org, MORITA Kazutaka , Stefan Hajnoczi Paolo Bonzini wrote: > Il 09/01/2013 14:04, Liu Yuan ha scritto: > > > > 2 The upper layer software which relies on the 'cache=xxx' to choose > > > > cache mode will fail its assumption against new QEMU. > > > > > > Which assumptions do you mean? As far as I can say the behaviour hasn't > > > changed, except possibly for the performance. > > > > When users set 'cache=writethrough' to export only a writethrough cache > > to Guest, but with new QEMU, it will actually get a writeback cache as > > default. > > They get a writeback cache implementation-wise, but they get a > writethrough cache safety-wise. How the cache is implemented doesn't > matter, as long as it "looks like" a writethrough cache. > > In fact, consider a local disk that doesn't support FUA. In old QEMU, > images used to be opened with O_DSYNC and that splits each write into > WRITE+FLUSH, just like new QEMU. All that changes is _where_ the > flushes are created. Old QEMU changes it in the kernel, new QEMU > changes it in userspace. > > > We don't need to communicate to the guest. I think 'cache=xxx' means > > what kind of cache the users *expect* to export to Guest OS. So if > > cache=writethrough set, Guest OS couldn't turn it to writeback cache > > magically. This is like I bought a disk with 'writethrough' cache > > built-in, I didn't expect that it turned to be a disk with writeback > > cache under the hood which could possible lose data when power outage > > happened. > > It's not by magic. It's by explicitly requesting the disk to do this. > > Perhaps it's a bug that the cache mode is not reset when the machine is > reset. I haven't checked that, but it would be a valid complaint. The question is, is cache=writeback/cache=writethrough an initial setting of guest-visible WCE that the guest is allowed to change, or is cache=writeththrough a way of saying "don't have a write cache" (which may or may not be reflected in the guest-visible disk id). I couldn't tell from QEMU documentation which is intended. It would be a bit silly if it means different things for different backend storage. I have seen (obscure) guest code which toggled WCE to simulate FUA, and there is plenty of advice out there saying to set WCE=0 for certain kinds of databases because of its presumed crash safety. Even very ancient guests on Linux and Windows can change WCE=0 with IDE and SCSI. So from a guest point of view, I think guest setting WCE=0 should mean exactly the same as FUA every write, or flush after every write, until guest setting WCE=1. -- Jamie