diff options
Diffstat (limited to 'fs/configfs/inode.c')
-rw-r--r-- | fs/configfs/inode.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index 5d349d38e05..4921e7426d9 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c | |||
@@ -33,10 +33,15 @@ | |||
33 | #include <linux/backing-dev.h> | 33 | #include <linux/backing-dev.h> |
34 | #include <linux/capability.h> | 34 | #include <linux/capability.h> |
35 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
36 | #include <linux/lockdep.h> | ||
36 | 37 | ||
37 | #include <linux/configfs.h> | 38 | #include <linux/configfs.h> |
38 | #include "configfs_internal.h" | 39 | #include "configfs_internal.h" |
39 | 40 | ||
41 | #ifdef CONFIG_LOCKDEP | ||
42 | static struct lock_class_key default_group_class[MAX_LOCK_DEPTH]; | ||
43 | #endif | ||
44 | |||
40 | extern struct super_block * configfs_sb; | 45 | extern struct super_block * configfs_sb; |
41 | 46 | ||
42 | static const struct address_space_operations configfs_aops = { | 47 | static const struct address_space_operations configfs_aops = { |
@@ -150,6 +155,38 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd) | |||
150 | return inode; | 155 | return inode; |
151 | } | 156 | } |
152 | 157 | ||
158 | #ifdef CONFIG_LOCKDEP | ||
159 | |||
160 | static void configfs_set_inode_lock_class(struct configfs_dirent *sd, | ||
161 | struct inode *inode) | ||
162 | { | ||
163 | int depth = sd->s_depth; | ||
164 | |||
165 | if (depth > 0) { | ||
166 | if (depth <= ARRAY_SIZE(default_group_class)) { | ||
167 | lockdep_set_class(&inode->i_mutex, | ||
168 | &default_group_class[depth - 1]); | ||
169 | } else { | ||
170 | /* | ||
171 | * In practice the maximum level of locking depth is | ||
172 | * already reached. Just inform about possible reasons. | ||
173 | */ | ||
174 | printk(KERN_INFO "configfs: Too many levels of inodes" | ||
175 | " for the locking correctness validator.\n"); | ||
176 | printk(KERN_INFO "Spurious warnings may appear.\n"); | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | |||
181 | #else /* CONFIG_LOCKDEP */ | ||
182 | |||
183 | static void configfs_set_inode_lock_class(struct configfs_dirent *sd, | ||
184 | struct inode *inode) | ||
185 | { | ||
186 | } | ||
187 | |||
188 | #endif /* CONFIG_LOCKDEP */ | ||
189 | |||
153 | int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *)) | 190 | int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *)) |
154 | { | 191 | { |
155 | int error = 0; | 192 | int error = 0; |
@@ -162,6 +199,7 @@ int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode * | |||
162 | struct inode *p_inode = dentry->d_parent->d_inode; | 199 | struct inode *p_inode = dentry->d_parent->d_inode; |
163 | p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; | 200 | p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; |
164 | } | 201 | } |
202 | configfs_set_inode_lock_class(sd, inode); | ||
165 | goto Proceed; | 203 | goto Proceed; |
166 | } | 204 | } |
167 | else | 205 | else |