mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: kosaki.motohiro@jp.fujitsu.com, Al Viro <viro@ZenIV.linux.org.uk>,
	linux-kernel@vger.kernel.org, Trond.Myklebust@netapp.com
Subject: Re: NFS lockdep lock misordering mmap_sem<->i_mutex_key with 2.6.32-git1
Date: Wed, 16 Dec 2009 09:06:12 +0900 (JST)	[thread overview]
Message-ID: <20091216085051.CDE2.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20091215233841.GE22392@basil.fritz.box>

> On Tue, Dec 15, 2009 at 10:21:34PM +0000, Al Viro wrote:
> > On Mon, Dec 07, 2009 at 02:20:09PM +0100, Andi Kleen wrote:
> > > >    nfs_readdir
> > > >      nfs_do_filldir
> > > >        filldir
> > > >          copy_to_user
> > > >            [page_fault]			[grab mmap_sem]
> > > > 
> > > >  sys_mmap				[grab mmap_sem]
> > > >    do_mmap_pgoff
> > > >      mmap_region
> > > >        nfs_file_mmap
> > > >          nfs_revalidate_mapping  
> > > >            nfs_invalidate_mapping	[grab i_mutex]
> > > > 
> > > > I guess recent lockdep improvement find old bug.
> > > 
> > > Thanks for the analysis.
> > > 
> > > I guess should never do copy_*_user while holding i_mutex? There might
> > > be lots of cases like that.
> > 
> > No.  mmap_sem inside i_mutex is the normal order; NFS mmap is doing the
> > wrong thing here.  Note that readdir() vs. NFS (file-only, thankfully ;-)
> > mmap() is a non-issue; NFS mmap() vs. write() is much more interesting.
> 
> I see.
> 
> > 
> > Again, a lot of mm/* code expects i_mutex, then mmap_sem order.  It's not
> > just readdir().
> 
> I suppose an easy workaround would be to not revalidate in mmap,
> because open should have already done that?
> 
> Very lightly tested RFC patch attached.
> 
> -Andi
> 
> ---
> 
> NFS: don't revalidate in mmap
> 
> nfs_revalidate_mapping takes i_mutex, but mmap already has mmap_sem
> hold and taking i_mutex inside mmap_sem is not allowed by the VFS.
> 
> So don't revalidate on mmap time and trust it has been already done.
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>

afaik, no revalidate mean "I don't mind the file was already removed
at server, I only care client handle".

What's happen if we mmap removed file? 





  parent reply	other threads:[~2009-12-16  0:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07 11:59 Andi Kleen
2009-12-07 12:19 ` KOSAKI Motohiro
2009-12-07 13:20   ` Andi Kleen
2009-12-07 17:38     ` KOSAKI Motohiro
2009-12-15 22:21     ` Al Viro
2009-12-15 23:38       ` Andi Kleen
2009-12-15 23:54         ` Trond Myklebust
2009-12-16  0:09           ` Al Viro
2009-12-16 13:16             ` Trond Myklebust
2009-12-23 16:32               ` Andi Kleen
2009-12-16  0:53           ` Andi Kleen
2009-12-16 13:09             ` Trond Myklebust
2009-12-16 15:57               ` Andi Kleen
2009-12-16  0:06         ` KOSAKI Motohiro [this message]
2009-12-16  0:48           ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091216085051.CDE2.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®