[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120403054528.GD15739@dhcp-172-17-9-228.mtv.corp.google.com>
Date: Mon, 2 Apr 2012 22:45:29 -0700
From: Joel Becker <jlbec@...lplan.org>
To: Hugh Dickins <hughd@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Christoph Hellwig <hch@...radead.org>,
Theodore Ts'o <tytso@....edu>,
Al Viro <viro@...iv.linux.org.uk>,
Alex Elder <elder@...nel.org>,
Andreas Dilger <adilger.kernel@...ger.ca>,
Ben Myers <bpm@....com>, Dave Chinner <david@...morbit.com>,
Mark Fasheh <mfasheh@...e.com>, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH] mm for fs: add truncate_pagecache_range
On Sun, Mar 25, 2012 at 01:26:10PM -0700, Hugh Dickins wrote:
> On Fri, 23 Mar 2012, Andrew Morton wrote:
> > On Fri, 23 Mar 2012 14:14:54 -0700 (PDT)
> > Hugh Dickins <hughd@...gle.com> wrote:
> > > On Fri, 23 Mar 2012, Andrew Morton wrote:
> > > >
> > > > --- a/mm/truncate.c~mm-for-fs-add-truncate_pagecache_range-fix
> > > > +++ a/mm/truncate.c
> > > > @@ -639,6 +639,9 @@ int vmtruncate_range(struct inode *inode
> > > > * with on-disk format, and the filesystem would not have to deal with
> > > > * situations such as writepage being called for a page that has already
> > > > * had its underlying blocks deallocated.
> > > > + *
> > > > + * Must be called with inode->i_mapping->i_mutex held.
> > >
> > > You catch me offguard: I forget whether that's an absolute requirement or
> > > just commonly the case. What do the other interfaces in truncate.c say ?-)
> >
> > i_mutex is generally required, to stabilise i_size.
>
> Sorry for being quarrelsome, but I do want to Nak your followup "fix".
>
> Building a test kernel quickly told me that inode->i_mapping->i_mutex
> doesn't exist, of course it's inode->i_mutex.
>
> Then running the test kernel quickly told me that neither ext4 nor xfs
> (I didn't try ocfs2) holds inode->i_mutex where holepunching calls
> truncate_inode_pages_range().
Just for completeness:
ocfs2 holds i_mutex around the entire ocfs2_change_file_space() call,
which can do hole punching and unwritten extent allocation (it is a
clone of xfs_change_file_space()). xfs itself seems hold its own idea
of a shared lock while doing the work and an exclusive lock around the
transaction join. I'm not clear enough about xfs to say how this
compares or even if I read it right.
But ocfs2 uses an allocation sem to protect allocation changes,
including i_size, so perhaps i_mutex isn't strictly necessary. I don't
think we contend enough here to try hard to remove it :-)
Joel
--
"The question of whether computers can think is just like the question
of whether submarines can swim."
- Edsger W. Dijkstra
http://www.jlbec.org/
jlbec@...lplan.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists