From: Christoph Hellwig Subject: Re: [PATCH, RFC] virtio_blk: add cache flush command Date: Tue, 12 May 2009 09:23:51 +0200 Message-ID: <20090512072351.GB5627@lst.de> References: <20090511083908.GB20082@lst.de> <4A083B7C.1000703@codemonkey.ws> <20090511154046.GA4226@lst.de> <4A08482E.30100@redhat.com> <20090511162810.GA6027@lst.de> <4A085721.2050005@redhat.com> <4A0864CE.10505@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , Christoph Hellwig , Rusty Russell , kvm@vger.kernel.org To: Anthony Liguori Return-path: Received: from verein.lst.de ([213.95.11.210]:44907 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754363AbZELHYL (ORCPT ); Tue, 12 May 2009 03:24:11 -0400 Content-Disposition: inline In-Reply-To: <4A0864CE.10505@codemonkey.ws> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, May 11, 2009 at 12:47:58PM -0500, Anthony Liguori wrote: > But how do we define the data integrity guarantees to the user of > cache=writeback+fsync? It seems to require a rather detailed knowledge > of Linux's use of T_FLUSH operations. It does work the same as for disks with writeback caches. If a barrier request completes the filesystem can assume all previous I/O on this disk has finished before the barrier request, and the barrier request has finished after these without any later request being finished before it. If a cache flush is issued the cache as of that point in time is flushed (used for fsync). > Right now, it's fairly easy to understand. cache=none and > cache=writethrough guarantee that all write operations that the guest > thinks have completed are completed. cache=writeback provides no such > guarantee. As said above with barriers it indeed does. > cache=writeback+fsync would guarantee that only operations that include > a T_FLUSH are present on disk which currently includes fsyncs but does > not include O_DIRECT writes. I guess whether O_SYNC does a T_FLUSH also > has to be determined. O_SYNC and O_DIRECT do it at least on XFS due to updating metadata after the write. I can't vouch for implementation details on other filesystems.