From: Christoph Hellwig Subject: Re: [PATCH] direct I/O fallback sync simplification Date: Sat, 26 Sep 2009 17:08:42 +0200 Message-ID: <20090926150842.GB11623@lst.de> References: <20090923130730.GC10759@lst.de> <20090923140430.GB15256@shareable.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Christoph Hellwig , Al Viro , Nick Piggin , Jan Kara , linux-fsdevel@vger.kernel.org To: Jamie Lokier Return-path: Received: from verein.lst.de ([213.95.11.210]:55562 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751401AbZIZPIn (ORCPT ); Sat, 26 Sep 2009 11:08:43 -0400 Content-Disposition: inline In-Reply-To: <20090923140430.GB15256@shareable.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Sep 23, 2009 at 03:04:30PM +0100, Jamie Lokier wrote: > Christoph Hellwig wrote: > > In the case of direct I/O falling back to buffered I/O we sync data > > twice currently: once at the end of generic_file_buffered_write using > > filemap_write_and_wait_range and once a little later in > > __generic_file_aio_write using do_sync_mapping_range with all flags set. > > > > The wait before write of the do_sync_mapping_range call does not make > > any sense, so just keep the filemap_write_and_wait_range call and move > > it to the right spot. > > Are you sure this is an expectation of O_DIRECT? > > A few notes from the net, including some documentation from IBM, > advise using O_DIRECT|O_DSYNC if you need sync when direct I/O falls > back to buffered on some other OSes. Not sure if we're on the same page here. Before the patch we do the following in case of a fallback buffered write when opened with O_DIRECT: - a filemap_write_and_wait_range in generic_file_buffered_write for (with a too long length, btw) - a do_sync_mapping_range(wait,write,wait) from __generic_file_aio_write which expands to (1) __filemap_fdatawrite_range(SYNC_ALL) (2) wait_on_page_writeback_range (3) wait_on_page_writeback_range (4) __filemap_fdatawrite_range(SYNC_ALL) (5) wait_on_page_writeback_range which clearly doesn't make any sense. The patch reduces it to (1) __filemap_fdatawrite_range(SYNC_ALL) (2) wait_on_page_writeback_range which does exactly the same, that is assuring the _data_ is on disk. That's still not O_DSNC or O_SYNC semantics, but that's an entirely different discussion.