diff options
-rw-r--r-- | fs/inode.c | 12 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c index bf6adf122c68..f97de0aeb3b6 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -567,6 +567,18 @@ EXPORT_SYMBOL(new_inode); | |||
567 | 567 | ||
568 | void unlock_new_inode(struct inode *inode) | 568 | void unlock_new_inode(struct inode *inode) |
569 | { | 569 | { |
570 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
571 | struct file_system_type *type = inode->i_sb->s_type; | ||
572 | /* | ||
573 | * ensure nobody is actually holding i_mutex | ||
574 | */ | ||
575 | mutex_destroy(&inode->i_mutex); | ||
576 | mutex_init(&inode->i_mutex); | ||
577 | if (inode->i_mode & S_IFDIR) | ||
578 | lockdep_set_class(&inode->i_mutex, &type->i_mutex_dir_key); | ||
579 | else | ||
580 | lockdep_set_class(&inode->i_mutex, &type->i_mutex_key); | ||
581 | #endif | ||
570 | /* | 582 | /* |
571 | * This is special! We do not need the spinlock | 583 | * This is special! We do not need the spinlock |
572 | * when clearing I_LOCK, because we're guaranteed | 584 | * when clearing I_LOCK, because we're guaranteed |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 0cad20e12585..6d760f1ad875 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1308,6 +1308,7 @@ struct file_system_type { | |||
1308 | 1308 | ||
1309 | struct lock_class_key i_lock_key; | 1309 | struct lock_class_key i_lock_key; |
1310 | struct lock_class_key i_mutex_key; | 1310 | struct lock_class_key i_mutex_key; |
1311 | struct lock_class_key i_mutex_dir_key; | ||
1311 | struct lock_class_key i_alloc_sem_key; | 1312 | struct lock_class_key i_alloc_sem_key; |
1312 | }; | 1313 | }; |
1313 | 1314 | ||