aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2008-10-15 18:50:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-10-23 05:13:16 -0400
commite2761a1167633ed943fea29002f990194923d060 (patch)
treee91816e85c7721fcff72e5f84336b1dde9d1ac17 /fs/namei.c
parent871c0067d53ba2dc35897c7da1da675bf4c70511 (diff)
[PATCH vfs-2.6 2/6] vfs: add d_ancestor()
This adds d_ancestor() instead of d_isparent(), then use it. If new_dentry == old_dentry, is_subdir() returns 1, looks strange. "new_dentry == old_dentry" is not subdir obviously. But I'm not checking callers for now, so this keeps current behavior. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 068a9e50c8c0..b7cd65224d60 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1454,20 +1454,18 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
1454 1454
1455 mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex); 1455 mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
1456 1456
1457 for (p = p1; !IS_ROOT(p); p = p->d_parent) { 1457 p = d_ancestor(p2, p1);
1458 if (p->d_parent == p2) { 1458 if (p) {
1459 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT); 1459 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT);
1460 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_CHILD); 1460 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_CHILD);
1461 return p; 1461 return p;
1462 }
1463 } 1462 }
1464 1463
1465 for (p = p2; !IS_ROOT(p); p = p->d_parent) { 1464 p = d_ancestor(p1, p2);
1466 if (p->d_parent == p1) { 1465 if (p) {
1467 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 1466 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
1468 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 1467 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);
1469 return p; 1468 return p;
1470 }
1471 } 1469 }
1472 1470
1473 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 1471 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);