提交 d1b72cc6 编写于 作者: M Miklos Szeredi 提交者: Al Viro

overlayfs: fix lockdep misannotation

In an overlay directory that shadows an empty lower directory, say
/mnt/a/empty102, do:

 	touch /mnt/a/empty102/x
 	unlink /mnt/a/empty102/x
 	rmdir /mnt/a/empty102

It's actually harmless, but needs another level of nesting between
I_MUTEX_CHILD and I_MUTEX_NORMAL.
Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
Tested-by: NDavid Howells <dhowells@redhat.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 c2096537
...@@ -2497,7 +2497,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2) ...@@ -2497,7 +2497,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
} }
mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT2);
return NULL; return NULL;
} }
EXPORT_SYMBOL(lock_rename); EXPORT_SYMBOL(lock_rename);
......
...@@ -571,7 +571,7 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list) ...@@ -571,7 +571,7 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
{ {
struct ovl_cache_entry *p; struct ovl_cache_entry *p;
mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_PARENT); mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_CHILD);
list_for_each_entry(p, list, l_node) { list_for_each_entry(p, list, l_node) {
struct dentry *dentry; struct dentry *dentry;
......
...@@ -639,11 +639,13 @@ static inline int inode_unhashed(struct inode *inode) ...@@ -639,11 +639,13 @@ static inline int inode_unhashed(struct inode *inode)
* 2: child/target * 2: child/target
* 3: xattr * 3: xattr
* 4: second non-directory * 4: second non-directory
* The last is for certain operations (such as rename) which lock two * 5: second parent (when locking independent directories in rename)
*
* I_MUTEX_NONDIR2 is for certain operations (such as rename) which lock two
* non-directories at once. * non-directories at once.
* *
* The locking order between these classes is * The locking order between these classes is
* parent -> child -> normal -> xattr -> second non-directory * parent[2] -> child -> grandchild -> normal -> xattr -> second non-directory
*/ */
enum inode_i_mutex_lock_class enum inode_i_mutex_lock_class
{ {
...@@ -651,7 +653,8 @@ enum inode_i_mutex_lock_class ...@@ -651,7 +653,8 @@ enum inode_i_mutex_lock_class
I_MUTEX_PARENT, I_MUTEX_PARENT,
I_MUTEX_CHILD, I_MUTEX_CHILD,
I_MUTEX_XATTR, I_MUTEX_XATTR,
I_MUTEX_NONDIR2 I_MUTEX_NONDIR2,
I_MUTEX_PARENT2,
}; };
void lock_two_nondirectories(struct inode *, struct inode*); void lock_two_nondirectories(struct inode *, struct inode*);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册