linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	samba-technical@lists.samba.org,
	Christoph Hellwig <hch@infradead.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 4/6] leases: break read leases on rename
Date: Fri, 23 Sep 2011 16:13:54 -0400	[thread overview]
Message-ID: <20110923201353.GH807@pad.fieldses.org> (raw)
In-Reply-To: <1316807905.3191.8.camel@localhost.localdomain>

On Fri, Sep 23, 2011 at 03:58:25PM -0400, Mimi Zohar wrote:
> On Fri, 2011-09-23 at 12:55 -0400, J. Bruce Fields wrote:
> > On Thu, Sep 22, 2011 at 01:17:49PM -0400, Mimi Zohar wrote:
> > > On Wed, 2011-09-21 at 10:58 -0400, J. Bruce Fields wrote: 
> > > > To rely on the i_mutex for exclusion between setlease and rename, we
> > > > need rename to take the i_mutex on the source as well as on any possible
> > > > target.
> > > > 
> > > > I suspect this is deadlock-free, but I need to think this proof through
> > > > again.  And I'm not sure what to do about lockdep.
> > > 
> > > Not sure that I will be of any help, but how about posting the lockdep
> > > messages?
> > 
> > Sure, appended below, but it's not particularly surprising--we're taking
> > i_mutex's on four different objects (both parents, source, and target if
> > any) where before there were three.
> > 
> > I suppose the solution is another i_mutex lock class, used only on the
> > lock of the source inode?
> > 
> > --b.
> 
> I must not be missing something, but it seems taking the i_mutex here is
> unnecessary.  fs/namei.c:lock_rename() already does all the locking for
> you.

There are up to four locks taken (before this patch):

	- the filesystem's rename lock
	- the i_mutex on the parents of the source and target
	- the i_mutex on the target (if it exists), which will be
	  unlinked when it's renamed over.

All but the last are taken care of by lock_rename(), yes.

This adds a fifth lock, i_mutex on the source.

The reason we add the lock is for mutual exclusion between rename and
setlease--we shouldn't grant leases on a file while a rename of that
file is in progress.

--b.

> 
> Mimi
> 
> > =============================================
> > [ INFO: possible recursive locking detected ]
> > 3.1.0-rc1-00076-g0e7e722 #599
> > ---------------------------------------------
> > mount/333 is trying to acquire lock:
> > (&sb->s_type->i_mutex_key#2){+.+.+.}, at: [<ffffffff811126d8>] vfs_rename+0x278/0x450
> > Sep 20 17:05:54 pip1 kernel:
> > but task is already holding lock:
> > (&sb->s_type->i_mutex_key#2){+.+.+.}, at: [<ffffffff81112b03>] sys_renameat+0x253/0x2d0
> > Sep 20 17:05:54 pip1 kernel:
> > other info that might help us debug this:
> > Possible unsafe locking scenario:
> > Sep 20 17:05:54 pip1 kernel:
> >       CPU0
> >       ----
> >  lock(&sb->s_type->i_mutex_key);
> >  lock(&sb->s_type->i_mutex_key);
> > Sep 20 17:05:54 pip1 kernel:
> > *** DEADLOCK ***
> > Sep 20 17:05:54 pip1 kernel:
> > May be due to missing lock nesting notation
> > Sep 20 17:05:54 pip1 kernel:
> > 2 locks held by mount/333:
> > #0: (&sb->s_type->i_mutex_key#2/1){+.+.+.}, at: [<ffffffff8110efc8>] lock_rename+0xe8/0xf0
> > #1:  (&sb->s_type->i_mutex_key#2){+.+.+.}, at: [<ffffffff81112b03>] sys_renameat+0x253/0x2d0
> > Sep 20 17:05:54 pip1 kernel:
> > stack backtrace:
> > Pid: 333, comm: mount Not tainted 3.1.0-rc1-00076-g0e7e722 #599
> > Call Trace:
> > [<ffffffff8107c9df>] __lock_acquire+0x15bf/0x1d80
> > [<ffffffff811126d8>] ?  vfs_rename+0x278/0x450
> > [<ffffffff8107d794>] lock_acquire+0x94/0x140
> > [<ffffffff811126d8>] ?  vfs_rename+0x278/0x450
> > [<ffffffff811126d8>] ?  vfs_rename+0x278/0x450
> > [<ffffffff81979d7f>] mutex_lock_nested+0x4f/0x360
> > [<ffffffff811126d8>] ?  vfs_rename+0x278/0x450
> > [<ffffffff8103b2b1>] ?  get_parent_ip+0x11/0x50
> > [<ffffffff8197ed9d>] ?  sub_preempt_count+0x9d/0xd0
> > [<ffffffff811126d8>] vfs_rename+0x278/0x450
> > [<ffffffff8103b2b1>] ?  get_parent_ip+0x11/0x50
> > [<ffffffff81112b5d>] sys_renameat+0x2ad/0x2d0
> > [<ffffffff810edab3>] ? remove_vma+0x53/0x70
> > [<ffffffff81079b0d>] ?  trace_hardirqs_on_caller+0xfd/0x190
> > [<ffffffff81079bad>] ?  trace_hardirqs_on+0xd/0x10
> > [<ffffffff810edab3>] ? remove_vma+0x53/0x70
> > [<ffffffff81982998>] ?  sysret_check+0x26/0x60
> > [<ffffffff81079b0d>] ?  trace_hardirqs_on_caller+0xfd/0x190
> > [<ffffffff81112b9b>] sys_rename+0x1b/0x20
> > [<ffffffff81982968>] system_call_fastpath+0x16/0x1b
> > 
> 
> 

  reply	other threads:[~2011-09-23 20:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-21 14:58 breaking leases on metadata changes J. Bruce Fields
2011-09-21 14:58 ` [PATCH 1/6] leases: split up generic_setlease into lock/unlock cases J. Bruce Fields
2011-09-22 17:16   ` Mimi Zohar
2011-09-23 18:57     ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 2/6] leases: fix write-open/read-lease race J. Bruce Fields
2011-09-21 15:01   ` J. Bruce Fields
2011-09-22 17:17     ` Mimi Zohar
2011-10-10 21:59   ` J. Bruce Fields
2011-10-11  6:19     ` Need information about the net ads user command Pankaj Baranwal
2011-10-28  8:46     ` [PATCH 2/6] leases: fix write-open/read-lease race J. Bruce Fields
2011-09-21 14:58 ` [PATCH 3/6] leases: break read leases on unlink J. Bruce Fields
2011-09-21 15:02   ` Christoph Hellwig
2011-09-21 17:41     ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 4/6] leases: break read leases on rename J. Bruce Fields
2011-09-22 17:17   ` Mimi Zohar
2011-09-23 16:55     ` J. Bruce Fields
2011-09-23 18:55       ` J. Bruce Fields
2011-09-23 19:58       ` Mimi Zohar
2011-09-23 20:13         ` J. Bruce Fields [this message]
2011-09-21 14:58 ` [PATCH 5/6] leases: break leases on any attribute modification J. Bruce Fields
2011-09-21 15:35   ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 6/6] leases: break read leases on link J. Bruce Fields
2011-09-24 18:36 ` breaking leases on metadata changes Stefan (metze) Metzmacher
2011-09-26 14:10   ` J. Bruce Fields
2011-09-26 16:16     ` J. Bruce Fields

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=20110923201353.GH807@pad.fieldses.org \
    --to=bfields@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zohar@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).