From: Arjan van de Ven <arjan@infradead.org>
To: Dave Jones <davej@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: 2.6.17-rc6-mm1
Date: Tue, 20 Jun 2006 19:42:29 +0200 [thread overview]
Message-ID: <1150825349.2891.219.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <20060608050047.GB16729@redhat.com>
On Thu, 2006-06-08 at 01:00 -0400, Dave Jones wrote:
> On Wed, Jun 07, 2006 at 10:47:24AM -0700, Andrew Morton wrote:
> >
> > ftp://ftp.kernel.org/pub/linux/kernel/peopleD/akpm/patches/2.6/2.6.17-rc6/2.6.17-rc6-mm1/
> >
> > - Many more lockdep updates
>
> Needs more.
>
> ====================================
> [ BUG: possible deadlock detected! ]
> ------------------------------------
> nfsd/11429 is trying to acquire lock:
> (&inode->i_mutex){--..}, at: [<c032286a>] mutex_lock+0x21/0x24
>
> but task is already holding lock:
> (&inode->i_mutex){--..}, at: [<c032286a>] mutex_lock+0x21/0x24
>
> which could potentially lead to deadlocks!
Does this fix it for you? (it fixes the case for me)
---
fs/nfsd/vfs.c | 10 +++++-----
include/linux/nfsd/nfsd.h | 1 -
include/linux/nfsd/nfsfh.h | 31 +++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 6 deletions(-)
Index: linux-2.6.17-rc6-mm2/fs/nfsd/vfs.c
===================================================================
--- linux-2.6.17-rc6-mm2.orig/fs/nfsd/vfs.c
+++ linux-2.6.17-rc6-mm2/fs/nfsd/vfs.c
@@ -1115,7 +1115,7 @@ nfsd_create(struct svc_rqst *rqstp, stru
*/
if (!resfhp->fh_dentry) {
/* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create */
- fh_lock(fhp);
+ fh_lock_parent(fhp);
dchild = lookup_one_len(fname, dentry, flen);
err = PTR_ERR(dchild);
if (IS_ERR(dchild))
@@ -1241,7 +1241,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, s
err = nfserr_notdir;
if(!dirp->i_op || !dirp->i_op->lookup)
goto out;
- fh_lock(fhp);
+ fh_lock_parent(fhp);
/*
* Compose the response file handle.
@@ -1426,7 +1426,7 @@ nfsd_symlink(struct svc_rqst *rqstp, str
err = fh_verify(rqstp, fhp, S_IFDIR, MAY_CREATE);
if (err)
goto out;
- fh_lock(fhp);
+ fh_lock_parent(fhp);
dentry = fhp->fh_dentry;
dnew = lookup_one_len(fname, dentry, flen);
err = PTR_ERR(dnew);
@@ -1495,7 +1495,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
if (isdotent(name, len))
goto out;
- fh_lock(ffhp);
+ fh_lock_parent(ffhp);
ddir = ffhp->fh_dentry;
dirp = ddir->d_inode;
@@ -1644,7 +1644,7 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
if (err)
goto out;
- fh_lock(fhp);
+ fh_lock_parent(fhp);
dentry = fhp->fh_dentry;
dirp = dentry->d_inode;
Index: linux-2.6.17-rc6-mm2/include/linux/nfsd/nfsd.h
===================================================================
--- linux-2.6.17-rc6-mm2.orig/include/linux/nfsd/nfsd.h
+++ linux-2.6.17-rc6-mm2/include/linux/nfsd/nfsd.h
@@ -67,7 +67,6 @@ int nfsd_svc(unsigned short port, int n
int nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp);
/* nfsd/vfs.c */
-int fh_lock_parent(struct svc_fh *, struct dentry *);
int nfsd_racache_init(int);
void nfsd_racache_shutdown(void);
int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
Index: linux-2.6.17-rc6-mm2/include/linux/nfsd/nfsfh.h
===================================================================
--- linux-2.6.17-rc6-mm2.orig/include/linux/nfsd/nfsfh.h
+++ linux-2.6.17-rc6-mm2/include/linux/nfsd/nfsfh.h
@@ -322,6 +322,37 @@ fh_lock(struct svc_fh *fhp)
}
/*
+ * Lock a file handle/inode to be used as parent dir for another
+ * NOTE: both fh_lock and fh_unlock are done "by hand" in
+ * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
+ * so, any changes here should be reflected there.
+ */
+static inline void
+fh_lock_parent(struct svc_fh *fhp)
+{
+ struct dentry *dentry = fhp->fh_dentry;
+ struct inode *inode;
+
+ dfprintk(FILEOP, "nfsd: fh_lock(%s) locked = %d\n",
+ SVCFH_fmt(fhp), fhp->fh_locked);
+
+ if (!fhp->fh_dentry) {
+ printk(KERN_ERR "fh_lock: fh not verified!\n");
+ return;
+ }
+ if (fhp->fh_locked) {
+ printk(KERN_WARNING "fh_lock: %s/%s already locked!\n",
+ dentry->d_parent->d_name.name, dentry->d_name.name);
+ return;
+ }
+
+ inode = dentry->d_inode;
+ mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
+ fill_pre_wcc(fhp);
+ fhp->fh_locked = 1;
+}
+
+/*
* Unlock a file handle/inode
*/
static inline void
next prev parent reply other threads:[~2006-06-20 17:42 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-07 17:47 2.6.17-rc6-mm1 Andrew Morton
2006-06-07 21:23 ` 2.6.17-rc6-mm1 J.A. Magallón
2006-06-07 22:07 ` 2.6.17-rc6-mm1 Ingo Molnar
2006-06-07 22:36 ` 2.6.17-rc6-mm1 J.A. Magallón
2006-06-07 23:54 ` 2.6.17-rc6-mm1 Stefan Richter
2006-06-08 0:31 ` 2.6.17-rc6-mm1 Chris Wright
2006-06-08 6:30 ` 2.6.17-rc6-mm1 Stefan Richter
2006-06-08 7:26 ` 2.6.17-rc6-mm1 Ingo Molnar
2006-06-07 21:54 ` 2.6.17-rc6-mm1 Rafael J. Wysocki
2006-06-07 22:11 ` 2.6.17-rc6-mm1 Ingo Molnar
2006-06-08 3:19 ` 2.6.17-rc6-mm1 Valdis.Kletnieks
2006-06-08 15:13 ` lockdep wierdness - was 2.6.17-rc6-mm1 Valdis.Kletnieks
2006-06-08 10:06 ` NTFS possible circular locking deadlock (Was: Re: 2.6.17-rc6-mm1) Duncan Sands
2006-06-12 14:35 ` Ingo Molnar
2006-06-08 12:54 ` 2.6.17-rc6-mm1 Rafael J. Wysocki
2006-06-07 22:31 ` 2.6.17-rc6-mm1 J.A. Magallón
2006-06-07 22:40 ` 2.6.17-rc6-mm1 Andrew Morton
2006-06-07 23:23 ` [PATCH] ignore smp_locks section warnings from init/exit code Randy.Dunlap
2006-06-08 0:04 ` Randy.Dunlap
2006-06-08 2:11 ` Jeff Dike
2006-06-08 2:32 ` Randy.Dunlap
2006-06-08 4:21 ` Jeff Dike
2006-06-08 4:29 ` Randy.Dunlap
2006-06-08 15:44 ` Randy.Dunlap
2006-06-08 18:35 ` Sam Ravnborg
2006-06-11 23:25 ` Jeff Dike
2006-06-12 0:17 ` Randy.Dunlap
2006-06-12 2:29 ` Jeff Dike
2006-06-12 2:52 ` Randy.Dunlap
2006-06-08 2:25 ` 2.6.17-rc6-mm1 Andi Kleen
2006-06-08 2:46 ` 2.6.17-rc6-mm1 Randy.Dunlap
2006-06-08 5:43 ` 2.6.17-rc6-mm1 Andi Kleen
2006-06-08 6:46 ` 2.6.17-rc6-mm1 Gerd Hoffmann
2006-06-07 23:14 ` 2.6.17-rc6-mm1 Martin Bligh
2006-06-07 23:55 ` 2.6.17-rc6-mm1 Andrew Morton
2006-06-08 1:09 ` 2.6.17-rc6-mm1 Grant Coady
2006-06-08 5:00 ` 2.6.17-rc6-mm1 Dave Jones
2006-06-20 17:42 ` Arjan van de Ven [this message]
2006-06-20 20:24 ` 2.6.17-rc6-mm1 Andrew Morton
2006-06-20 20:38 ` 2.6.17-rc6-mm1 Arjan van de Ven
2006-06-21 6:23 ` 2.6.17-rc6-mm1 Dave Jones
2006-06-21 8:15 ` 2.6.17-rc6-mm1 Arjan van de Ven
2006-06-21 18:42 ` 2.6.17-rc6-mm1 Dave Jones
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=1150825349.2891.219.camel@laptopd505.fenrus.org \
--to=arjan@infradead.org \
--cc=akpm@osdl.org \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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®