From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MiFfn-0005Ho-SD for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:48:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MiFfi-0005Fr-80 for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:48:26 -0400 Received: from [199.232.76.173] (port=38709 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MiFfi-0005Fm-3H for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:48:22 -0400 Received: from mail2.shareable.org ([80.68.89.115]:51243) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MiFfh-0000wn-AH for qemu-devel@nongnu.org; Mon, 31 Aug 2009 18:48:21 -0400 Date: Mon, 31 Aug 2009 23:48:19 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH 2/4] block: use fdatasync instead of fsync Message-ID: <20090831224819.GE24318@shareable.org> References: <20090831201627.GA4811@lst.de> <20090831201709.GB4874@lst.de> <20090831215138.GA24318@shareable.org> <20090831215525.GA8135@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090831215525.GA8135@lst.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org Christoph Hellwig wrote: > On Mon, Aug 31, 2009 at 10:51:38PM +0100, Jamie Lokier wrote: > > Christoph Hellwig wrote: > > > > > > If we are flushing the caches for our image files we only care about the > > > data (including the metadata required for accessing it) but not things > > > like timestamp updates. So use fdatasync instead of fsync to implement > > > the flush operations. > > > > > - fsync(s->fd); > > > + fdatasync(s->fd); > > > > I believe fsync was used because of uncertainty about whether > > fdatasync reliably flushes the necessary metadata to access the data > > on all hosts, after things like writing to holes and extending a file. > > > > I'm still not sure if fdatasync provides that guarantee on Linux. > > fdatasync is defined to provide that guarantee, and modulo the whole > clusterfuck around volatile write caches it does the right thing > thing on common Linux filesystems. That's good to know. I'm not sure about other hosts though. It's specified to update the metadata, but I think I've encountered people saying it doesn't - specifically when extending a file, that it doesn't guarantee the file size is extended on some OSes. But that might be an urban myth. -- Jamie