Re: lockdep wierdness...

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Christoph Hellwig <hch@...>
Cc: Steven Rostedt <rostedt@...>, Trond Myklebust <Trond.Myklebust@...>, Andrew Morton <akpm@...>, Ingo Molnar <mingo@...>, <linux-kernel@...>, Jan Kara <jack@...>
Date: Thursday, September 27, 2007 - 11:58 am

On Thu, 2007-09-27 at 15:00 +0100, Christoph Hellwig wrote:

How about this:

---
Make a distinction between file and dir usage of i_mutex.

The inode should be complete and unused at unlock_new_inode(), re-init
i_mutex depending on its type.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 fs/inode.c         |   12 ++++++++++++
 include/linux/fs.h |    1 +
 2 files changed, 13 insertions(+)

Index: linux-2.6/fs/inode.c
===================================================================
--- linux-2.6.orig/fs/inode.c
+++ linux-2.6/fs/inode.c
@@ -576,6 +576,18 @@ EXPORT_SYMBOL(new_inode);
 
 void unlock_new_inode(struct inode *inode)
 {
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+	struct file_system_type *type = inode->i_sb->s_type;
+	/*
+	 * ensure nobody is actually holding i_mutex
+	 */
+	mutex_destroy(&inode->i_mutex);
+	mutex_init(&inode->i_mutex);
+	if (inode->i_mode & S_IFDIR)
+		lockdep_set_class(&inode->i_mutex, &type->i_mutex_dir_key);
+	else
+		lockdep_set_class(&inode->i_mutex, &type->i_mutex_key);
+#endif
 	/*
 	 * This is special!  We do not need the spinlock
 	 * when clearing I_LOCK, because we're guaranteed
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h
+++ linux-2.6/include/linux/fs.h
@@ -1426,6 +1426,7 @@ struct file_system_type {
 
 	struct lock_class_key i_lock_key;
 	struct lock_class_key i_mutex_key;
+	struct lock_class_key i_mutex_dir_key;
 	struct lock_class_key i_alloc_sem_key;
 };
 


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
lockdep wierdness..., Trond Myklebust, (Mon Sep 24, 6:07 pm)
Re: lockdep wierdness..., Steven Rostedt, (Mon Sep 24, 10:13 pm)
Re: lockdep wierdness..., Peter Zijlstra, (Thu Sep 27, 9:51 am)
Re: lockdep wierdness..., Christoph Hellwig, (Thu Sep 27, 10:00 am)
Re: lockdep wierdness..., Peter Zijlstra, (Thu Sep 27, 11:58 am)