From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: with ECARTIS (v1.0.0; list xfs); Thu, 08 Feb 2007 14:31:24 -0800 (PST) Received: from larry.melbourne.sgi.com (larry.melbourne.sgi.com [134.14.52.130]) by oss.sgi.com (8.12.10/8.12.10/SuSE Linux 0.7) with SMTP id l18MVGm7005141 for ; Thu, 8 Feb 2007 14:31:18 -0800 Date: Fri, 9 Feb 2007 09:30:58 +1100 From: David Chinner Subject: Re: [PATCH 1 of 2] Implement generic block_page_mkwrite() functionality Message-ID: <20070208223058.GV44411608@melbourne.sgi.com> References: <20070207124922.GK44411608@melbourne.sgi.com> <20070207144415.GN44411608@melbourne.sgi.com> <20070207225013.GQ44411608@melbourne.sgi.com> <20070208131100.GH11967@think.oraclecorp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070208131100.GH11967@think.oraclecorp.com> Sender: xfs-bounce@oss.sgi.com Errors-to: xfs-bounce@oss.sgi.com List-Id: xfs To: Chris Mason Cc: David Chinner , Hugh Dickins , xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org On Thu, Feb 08, 2007 at 08:11:00AM -0500, Chris Mason wrote: > On Thu, Feb 08, 2007 at 09:50:13AM +1100, David Chinner wrote: > > > You don't need to lock out all truncation, but you do need to lock > > > out truncation of the page in question. Instead of your i_size > > > checks, check page->mapping isn't NULL after the lock_page? > > > > Yes, that can be done, but we still need to know if part of > > the page is beyond EOF for when we call block_commit_write() > > and mark buffers dirty. Hence we need to check the inode size. > > > > I guess if we block the truncate with the page lock, then the > > inode size is not going to change until we unlock the page. > > If the inode size has already been changed but the page not yet > > removed from the mapping we'll be beyond EOF. > > > > So it seems to me that we can get away with not using the i_mutex > > in the generic code here. > > vmtruncate changes the inode size before waiting on any pages. So, > i_size could change any time during page_mkwrite. Which would put us beyond EOF. Ok. > It would be a good idea to read i_size once and put it in a local var > instead. Will do - I'll snap it once the page is locked.... Thanks Chris. Cheers, Dave. -- Dave Chinner Principal Engineer SGI Australian Software Group