From: Nick Piggin Subject: Re: [patch 4/5] tmpfs: convert to use the new truncate convention Date: Mon, 17 Aug 2009 09:32:55 +0200 Message-ID: <20090817073255.GE9962@wotan.suse.de> References: <20090816102533.329473921@suse.de> <20090816102856.691691068@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Morton , linux-fsdevel@vger.kernel.org, Christoph Hellwig To: Hugh Dickins Return-path: Received: from cantor2.suse.de ([195.135.220.15]:33976 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751276AbZHQHcy (ORCPT ); Mon, 17 Aug 2009 03:32:54 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, Aug 16, 2009 at 07:38:51PM +0100, Hugh Dickins wrote: > On Sun, 16 Aug 2009, npiggin@suse.de wrote: > > mm/shmem.c | 35 +++++++++++++++++++---------------- > > 1 file changed, 19 insertions(+), 16 deletions(-) > > That looks fine to me, thanks Nick, with one reservation: > there is no case (at present anyway) in which simple_setsize() > can fail with non-NULL page to release; but that does depend upon > some inside knowledge, so it'll look less worrying if we move up > the page_cache_release. Please fold the below patch in to add my Ah good point, that looks much better. Thanks Hugh. > > Acked-by: Hugh Dickins > > --- 2.6.31-rc6-trunc/mm/shmem.c 2009-08-16 17:09:57.000000000 +0100 > +++ linux/mm/shmem.c 2009-08-16 19:11:51.000000000 +0100 > @@ -767,13 +767,13 @@ done2: > static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) > { > struct inode *inode = dentry->d_inode; > - struct page *page = NULL; > int error; > > if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) { > loff_t newsize = attr->ia_size; > + struct page *page = NULL; > > - if (attr->ia_size < inode->i_size) { > + if (newsize < inode->i_size) { > /* > * If truncating down to a partial page, then > * if that page is already allocated, hold it > @@ -804,6 +804,8 @@ static int shmem_notify_change(struct de > } > > error = simple_setsize(inode, newsize); > + if (page) > + page_cache_release(page); > if (error) > return error; > shmem_truncate_range(inode, newsize, (loff_t)-1); > @@ -817,8 +819,6 @@ static int shmem_notify_change(struct de > if (!error && (attr->ia_valid & ATTR_MODE)) > error = generic_acl_chmod(inode, &shmem_acl_ops); > #endif > - if (page) > - page_cache_release(page); > return error; > } >