提交 d63a5a74 编写于 作者: N NeilBrown 提交者: Linus Torvalds

[PATCH] lockdep: avoid lockdep warning in md

md_open takes ->reconfig_mutex which causes lockdep to complain.  This
(normally) doesn't have deadlock potential as the possible conflict is with a
reconfig_mutex in a different device.

I say "normally" because if a loop were created in the array->member hierarchy
a deadlock could happen.  However that causes bigger problems than a deadlock
and should be fixed independently.

So we flag the lock in md_open as a nested lock.  This requires defining
mutex_lock_interruptible_nested.

Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NNeil Brown <neilb@suse.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 6796bf54
...@@ -4423,7 +4423,7 @@ static int md_open(struct inode *inode, struct file *file) ...@@ -4423,7 +4423,7 @@ static int md_open(struct inode *inode, struct file *file)
mddev_t *mddev = inode->i_bdev->bd_disk->private_data; mddev_t *mddev = inode->i_bdev->bd_disk->private_data;
int err; int err;
if ((err = mddev_lock(mddev))) if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1)))
goto out; goto out;
err = 0; err = 0;
......
...@@ -125,8 +125,10 @@ extern int fastcall mutex_lock_interruptible(struct mutex *lock); ...@@ -125,8 +125,10 @@ extern int fastcall mutex_lock_interruptible(struct mutex *lock);
#ifdef CONFIG_DEBUG_LOCK_ALLOC #ifdef CONFIG_DEBUG_LOCK_ALLOC
extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
extern int mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass);
#else #else
# define mutex_lock_nested(lock, subclass) mutex_lock(lock) # define mutex_lock_nested(lock, subclass) mutex_lock(lock)
# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
#endif #endif
/* /*
......
...@@ -206,6 +206,15 @@ mutex_lock_nested(struct mutex *lock, unsigned int subclass) ...@@ -206,6 +206,15 @@ mutex_lock_nested(struct mutex *lock, unsigned int subclass)
} }
EXPORT_SYMBOL_GPL(mutex_lock_nested); EXPORT_SYMBOL_GPL(mutex_lock_nested);
int __sched
mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass)
{
might_sleep();
return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, subclass);
}
EXPORT_SYMBOL_GPL(mutex_lock_interruptible_nested);
#endif #endif
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册