From: Stefano Stabellini Subject: Re: [PATCH 1/3] qemu-xen-traditional: use O_DIRECT to open disk images for IDE Date: Thu, 29 Mar 2012 18:18:40 +0100 Message-ID: References: <1332514289-28129-1-git-send-email-stefano.stabellini@eu.citrix.com> <20337.63345.79209.977387@mariner.uk.xensource.com> <1332925851.7702.9.camel@zakaz.uk.xensource.com> <20340.28608.642720.913130@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20340.28608.642720.913130@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: "Zhang, Yang Z" , "xen-devel@lists.xensource.com" , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thu, 29 Mar 2012, Ian Jackson wrote: > Ian Campbell writes ("Re: [Xen-devel] [PATCH 1/3] qemu-xen-traditional: use O_DIRECT to open disk images for IDE"): > > commit 82787c6f689d869ad349df83ec3f58702afe00fe > > Author: Ian Jackson > > Date: Mon Mar 2 11:21:51 2009 +0000 > > > > Override default cache mode for disk images to write-back > > > > Upstream qemu changed the default cache mode to write-through (ie, > > O_DSYNC) which is much slower. We do not need this as we have > > explicit control of cacheing with the IDE cache control commands. > ... > > OK, so the reason for this is as follows: > > There are IDE commands for controlling cacheing in the disk. These > are the commands 0x02 and 0x82 (near l.2666 of hw/ide.c in > qemu-xen-unstable). If the host has enabled the write cache, the disk > is allowed to buffer written data in its own ram. The host is > expected to either disable the cache, or flush the cache > (WIN_FLUSH_CACHE, near l.2717) as and when appropriate. > > We implement this in qemu-xen-unstable as follows: > > The bdrv_write calls are expected to be write-back cached. The cache > enable/disable commands set a variable write_cache in the ide code. > If write_cache is 0, we run bdrv_flush after each write. In any case > we run bdrv_flush when we get a cache flush command. bdrv_flush > calls, effectively, fsync(). > > So I think qemu-xen-unstable the use of write-back cacheing for > bdrv_write is correct. (Apart from the wrinkle that the emulated > drive cache, write_cache, is enabled by default - but I wouldn't be > surprised if that accurately emulated the behaviour of real disks.) You have missed my other emails on this thread about other disk formats and related bug reports. > How is this done in qemu-upstream ? WIN_FLUSH_CACHE calls ide_flush_cache that calls bdrv_aio_flush.