提交 cf516249 编写于 作者: I Ingo Molnar 提交者: Linus Torvalds

[PATCH] lockdep: annotate ->s_lock

Teach special (per-filesystem) locking code to the lock validator.

Minimal effect on non-lockdep kernels: one extra parameter to alloc_super().
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 91ebe2a9
...@@ -53,7 +53,7 @@ DEFINE_SPINLOCK(sb_lock); ...@@ -53,7 +53,7 @@ DEFINE_SPINLOCK(sb_lock);
* Allocates and initializes a new &struct super_block. alloc_super() * Allocates and initializes a new &struct super_block. alloc_super()
* returns a pointer new superblock or %NULL if allocation had failed. * returns a pointer new superblock or %NULL if allocation had failed.
*/ */
static struct super_block *alloc_super(void) static struct super_block *alloc_super(struct file_system_type *type)
{ {
struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER);
static struct super_operations default_op; static struct super_operations default_op;
...@@ -72,6 +72,12 @@ static struct super_block *alloc_super(void) ...@@ -72,6 +72,12 @@ static struct super_block *alloc_super(void)
INIT_LIST_HEAD(&s->s_inodes); INIT_LIST_HEAD(&s->s_inodes);
init_rwsem(&s->s_umount); init_rwsem(&s->s_umount);
mutex_init(&s->s_lock); mutex_init(&s->s_lock);
/*
* The locking rules for s_lock are up to the
* filesystem. For example ext3fs has different
* lock ordering than usbfs:
*/
lockdep_set_class(&s->s_lock, &type->s_lock_key);
down_write(&s->s_umount); down_write(&s->s_umount);
s->s_count = S_BIAS; s->s_count = S_BIAS;
atomic_set(&s->s_active, 1); atomic_set(&s->s_active, 1);
...@@ -295,7 +301,7 @@ struct super_block *sget(struct file_system_type *type, ...@@ -295,7 +301,7 @@ struct super_block *sget(struct file_system_type *type,
} }
if (!s) { if (!s) {
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
s = alloc_super(); s = alloc_super(type);
if (!s) if (!s)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
goto retry; goto retry;
......
...@@ -1295,6 +1295,7 @@ struct file_system_type { ...@@ -1295,6 +1295,7 @@ struct file_system_type {
struct module *owner; struct module *owner;
struct file_system_type * next; struct file_system_type * next;
struct list_head fs_supers; struct list_head fs_supers;
struct lock_class_key s_lock_key;
}; };
extern int get_sb_bdev(struct file_system_type *fs_type, extern int get_sb_bdev(struct file_system_type *fs_type,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册