Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 31814
b: refs/heads/master
c: f2eace2
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Jul 3, 2006
1 parent 5d53cc0 commit 32d0c35
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a90b9c05df3c1e58eaedc28795d0f5abd896c098
refs/heads/master: f2eace23e924bd3f05aedea4fc505eb5508d2d93
2 changes: 1 addition & 1 deletion trunk/drivers/usb/core/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static void update_sb(struct super_block *sb)
if (!root)
return;

mutex_lock(&root->d_inode->i_mutex);
mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_PARENT);

list_for_each_entry(bus, &root->d_subdirs, d_u.d_child) {
if (bus->d_inode) {
Expand Down
20 changes: 10 additions & 10 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,30 +1423,30 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
struct dentry *p;

if (p1 == p2) {
mutex_lock(&p1->d_inode->i_mutex);
mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
return NULL;
}

mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex);

for (p = p1; p->d_parent != p; p = p->d_parent) {
if (p->d_parent == p2) {
mutex_lock(&p2->d_inode->i_mutex);
mutex_lock(&p1->d_inode->i_mutex);
mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT);
mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_CHILD);
return p;
}
}

for (p = p2; p->d_parent != p; p = p->d_parent) {
if (p->d_parent == p1) {
mutex_lock(&p1->d_inode->i_mutex);
mutex_lock(&p2->d_inode->i_mutex);
mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);
return p;
}
}

mutex_lock(&p1->d_inode->i_mutex);
mutex_lock(&p2->d_inode->i_mutex);
mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);
return NULL;
}

Expand Down Expand Up @@ -1751,7 +1751,7 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir)
{
struct dentry *dentry = ERR_PTR(-EEXIST);

mutex_lock(&nd->dentry->d_inode->i_mutex);
mutex_lock_nested(&nd->dentry->d_inode->i_mutex, I_MUTEX_PARENT);
/*
* Yucky last component or no last component at all?
* (foo/., foo/.., /////)
Expand Down Expand Up @@ -2008,7 +2008,7 @@ static long do_rmdir(int dfd, const char __user *pathname)
error = -EBUSY;
goto exit1;
}
mutex_lock(&nd.dentry->d_inode->i_mutex);
mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
dentry = lookup_hash(&nd);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
Expand Down Expand Up @@ -2082,7 +2082,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
error = -EISDIR;
if (nd.last_type != LAST_NORM)
goto exit1;
mutex_lock(&nd.dentry->d_inode->i_mutex);
mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
dentry = lookup_hash(&nd);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
Expand Down
19 changes: 19 additions & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,25 @@ struct inode {
#endif
};

/*
* inode->i_mutex nesting subclasses for the lock validator:
*
* 0: the object of the current VFS operation
* 1: parent
* 2: child/target
* 3: quota file
*
* The locking order between these classes is
* parent -> child -> normal -> quota
*/
enum inode_i_mutex_lock_class
{
I_MUTEX_NORMAL,
I_MUTEX_PARENT,
I_MUTEX_CHILD,
I_MUTEX_QUOTA
};

/*
* NOTE: in a 32bit arch with a preemptable kernel and
* an UP compile the i_size_read/write must be atomic
Expand Down

0 comments on commit 32d0c35

Please sign in to comment.