public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederik Deweerdt <deweerdt@free.fr>
To: Laurent Riffard <laurent.riffard@free.fr>
Cc: Kernel development list <linux-kernel@vger.kernel.org>,
	Oliver Neukum <oliver@neukum.name>, Greg KH <greg@kroah.com>,
	Maneesh Soni <maneesh@in.ibm.com>, Andrew Morton <akpm@osdl.org>
Subject: Re: 2.6.20-rc2-mm1: INFO: possible recursive locking detected in con_close
Date: Fri, 29 Dec 2006 11:00:41 +0000	[thread overview]
Message-ID: <20061229110041.GA1441@slug> (raw)
In-Reply-To: <45943638.30705@free.fr>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 3143 bytes --]

On Thu, Dec 28, 2006 at 10:25:12PM +0100, Laurent Riffard wrote:
> Le 28.12.2006 11:42, Andrew Morton a écrit :
> >ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.20-rc2/2.6.20-rc2-mm1/
> 
> Hello,
> 
> got this with 2.6.20-rc2-mm1, reverting 
> gregkh-driver-driver-core-fix-race-in-sysfs-between-sysfs_remove_file-and-read-write.patch made it disappear.
> 
Hi, 

This is due to sysfs_hash_and_remove() holding dir->d_inode->i_mutex
before calling sysfs_drop_dentry() which calls orphan_all_buffers()
which in turn takes node->i_mutex.
The following patch solves the problem by defering the buffers orphaning
after the dir->d_inode->imutex is released. Not sure it's the best
solution though, Greg?

Regards,
Frederik

Signed-off-by: Frederik Deweerdt <frederik.deweerdt@gmail.com>

diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 8c533cb..7cac0b6 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -230,10 +230,10 @@ static inline void orphan_all_buffers(struct inode *node)
  * Unhashes the dentry corresponding to given sysfs_dirent
  * Called with parent inode's i_mutex held.
  */
-void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
+struct inode *sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
 {
 	struct dentry * dentry = sd->s_dentry;
-	struct inode *inode;
+	struct inode *inode = NULL;
 
 	if (dentry) {
 		spin_lock(&dcache_lock);
@@ -248,19 +248,19 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
 			spin_unlock(&dentry->d_lock);
 			spin_unlock(&dcache_lock);
 			simple_unlink(parent->d_inode, dentry);
-			orphan_all_buffers(inode);
-			iput(inode);
 		} else {
 			spin_unlock(&dentry->d_lock);
 			spin_unlock(&dcache_lock);
 		}
 	}
+	return inode;
 }
 
 int sysfs_hash_and_remove(struct dentry * dir, const char * name)
 {
 	struct sysfs_dirent * sd;
 	struct sysfs_dirent * parent_sd;
+	struct inode *inode;
 	int found = 0;
 
 	if (!dir)
@@ -277,7 +277,7 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
 			continue;
 		if (!strcmp(sysfs_get_name(sd), name)) {
 			list_del_init(&sd->s_sibling);
-			sysfs_drop_dentry(sd, dir);
+			inode = sysfs_drop_dentry(sd, dir);
 			sysfs_put(sd);
 			found = 1;
 			break;
@@ -285,5 +285,10 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
 	}
 	mutex_unlock(&dir->d_inode->i_mutex);
 
+	if (found == 1 && inode) {
+		orphan_all_buffers(inode);
+		iput(inode);
+	}
+
 	return found ? 0 : -ENOENT;
 }
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 5100a12..ef9d217 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -17,7 +17,7 @@ extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **)
 extern void sysfs_remove_subdir(struct dentry *);
 
 extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd);
-extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
+extern struct inode * sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
 extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
 
 extern struct rw_semaphore sysfs_rename_sem;

  reply	other threads:[~2006-12-29 11:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-28 10:42 2.6.20-rc2-mm1 Andrew Morton
2006-12-28 15:26 ` [-mm patch] DVB: fix compile error Adrian Bunk
2006-12-28 21:25 ` 2.6.20-rc2-mm1: INFO: possible recursive locking detected in con_close Laurent Riffard
2006-12-29 11:00   ` Frederik Deweerdt [this message]
2006-12-29 13:06     ` Laurent Riffard
2007-01-05  1:10     ` Greg KH
2007-01-05 10:57       ` Frederik Deweerdt
2006-12-29  0:36 ` 2.6.20-rc2-mm1: i386-idle-notifier again Adrian Bunk
2006-12-29  2:10 ` [-mm patch] infiniband/ulp/ipoib/ipoib_cm.c: make functions static Adrian Bunk
2006-12-29  5:39   ` Michael S. Tsirkin
2006-12-29  2:10 ` [-mm patch] make usbvision_rvfree() static Adrian Bunk
2006-12-29  2:10 ` [-mm patch] drivers/mtd/ubi/vtbl.c: make 2 functions static Adrian Bunk
2006-12-29 11:05 ` [-mm patch] add KM_SKB_DATA_SOFTIRQ to kmap_atomic debugging Frederik Deweerdt

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=20061229110041.GA1441@slug \
    --to=deweerdt@free.fr \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=laurent.riffard@free.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maneesh@in.ibm.com \
    --cc=oliver@neukum.name \
    /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