Some filesystems need to set lockdep map for i_mutex differently for
different directories. For a filesystem it is naturaly done when the
inode is read but we have to modify unlock_new_inode() not to overwrite
the lockdep map filesystem has set.

CC: [email protected]
CC: [email protected]
Signed-off-by: Jan Kara <[email protected]>
---
 fs/inode.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index 913ab2d..c8c36cf 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -640,12 +640,16 @@ void unlock_new_inode(struct inode *inode)
        if (inode->i_mode & S_IFDIR) {
                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);
-               lockdep_set_class(&inode->i_mutex, &type->i_mutex_dir_key);
+               /* Set new key only if filesystem haven't already changed it */
+               if (inode->i_mutex.dep_map.key != &type->i_mutex_key) {
+                       /*
+                        * ensure nobody is actually holding i_mutex
+                        */
+                       mutex_destroy(&inode->i_mutex);
+                       mutex_init(&inode->i_mutex);
+                       lockdep_set_class(&inode->i_mutex,
+                                         &type->i_mutex_dir_key);
+               }
        }
 #endif
        /*
-- 
1.6.0.2


_______________________________________________
Ocfs2-devel mailing list
[email protected]
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

Reply via email to