Commit 978d6d8c authored by Tyler Hicks's avatar Tyler Hicks Committed by Al Viro

vfs: Correctly set the dir i_mutex lockdep class

9a7aa12f introduced additional logic around setting the i_mutex
lockdep class for directory inodes. The idea was that some filesystems
may want their own special lockdep class for different directory
inodes and calling unlock_new_inode() should not clobber one of
those special classes.

I believe that the added conditional, around the *negated* return value
of lockdep_match_class(), caused directory inodes to be placed in the
wrong lockdep class.

inode_init_always() sets the i_mutex lockdep class with i_mutex_key for
all inodes. If the filesystem did not change the class during inode
initialization, then the conditional mentioned above was false and the
directory inode was incorrectly left in the non-directory lockdep class.
If the filesystem did set a special lockdep class, then the conditional
mentioned above was true and that class was clobbered with
i_mutex_dir_key.

This patch removes the negation from the conditional so that the i_mutex
lockdep class is properly set for directory inodes. Special classes are
preserved and directory inodes with unmodified classes are set with
i_mutex_dir_key.
Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c7b28555
...@@ -938,8 +938,7 @@ void lockdep_annotate_inode_mutex_key(struct inode *inode) ...@@ -938,8 +938,7 @@ void lockdep_annotate_inode_mutex_key(struct inode *inode)
struct file_system_type *type = inode->i_sb->s_type; struct file_system_type *type = inode->i_sb->s_type;
/* Set new key only if filesystem hasn't already changed it */ /* Set new key only if filesystem hasn't already changed it */
if (!lockdep_match_class(&inode->i_mutex, if (lockdep_match_class(&inode->i_mutex, &type->i_mutex_key)) {
&type->i_mutex_key)) {
/* /*
* ensure nobody is actually holding i_mutex * ensure nobody is actually holding i_mutex
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment