Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH vfs-2.6 1/6] vfs: replace parent == dentry->d_parent by IS_ROOT()

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

authored by

OGAWA Hirofumi and committed by
Al Viro
871c0067 9fbb76ce

+14 -11
+12 -9
fs/dcache.c
··· 174 174 dentry_stat.nr_dentry--; /* For d_free, below */ 175 175 /*drops the locks, at that point nobody can reach this dentry */ 176 176 dentry_iput(dentry); 177 - parent = dentry->d_parent; 177 + if (IS_ROOT(dentry)) 178 + parent = NULL; 179 + else 180 + parent = dentry->d_parent; 178 181 d_free(dentry); 179 - return dentry == parent ? NULL : parent; 182 + return parent; 180 183 } 181 184 182 185 /* ··· 669 666 BUG(); 670 667 } 671 668 672 - parent = dentry->d_parent; 673 - if (parent == dentry) 669 + if (IS_ROOT(dentry)) 674 670 parent = NULL; 675 - else 671 + else { 672 + parent = dentry->d_parent; 676 673 atomic_dec(&parent->d_count); 674 + } 677 675 678 676 list_del(&dentry->d_u.d_child); 679 677 detached++; ··· 1727 1723 { 1728 1724 struct dentry *p; 1729 1725 1730 - for (p = p2; p->d_parent != p; p = p->d_parent) { 1726 + for (p = p2; !IS_ROOT(p); p = p->d_parent) { 1731 1727 if (p->d_parent == p1) 1732 1728 return 1; 1733 1729 } ··· 2172 2168 seq = read_seqbegin(&rename_lock); 2173 2169 for (;;) { 2174 2170 if (new_dentry != old_dentry) { 2175 - struct dentry * parent = new_dentry->d_parent; 2176 - if (parent == new_dentry) 2171 + if (IS_ROOT(new_dentry)) 2177 2172 break; 2178 - new_dentry = parent; 2173 + new_dentry = new_dentry->d_parent; 2179 2174 continue; 2180 2175 } 2181 2176 result = 1;
+2 -2
fs/namei.c
··· 1454 1454 1455 1455 mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex); 1456 1456 1457 - for (p = p1; p->d_parent != p; p = p->d_parent) { 1457 + for (p = p1; !IS_ROOT(p); p = p->d_parent) { 1458 1458 if (p->d_parent == p2) { 1459 1459 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT); 1460 1460 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_CHILD); ··· 1462 1462 } 1463 1463 } 1464 1464 1465 - for (p = p2; p->d_parent != p; p = p->d_parent) { 1465 + for (p = p2; !IS_ROOT(p); p = p->d_parent) { 1466 1466 if (p->d_parent == p1) { 1467 1467 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 1468 1468 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);