aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-09 13:51:19 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:32:55 -0400
commitb3d9b7a3c752dc4b6976a4ff7b8298887a5b734d (patch)
treece0d4c84328890dd63c9c4cb3e281b6b3476f85f /fs/dcache.c
parent9f713878f22e0b2d34d62df0ca55f65166375634 (diff)
vfs: switch i_dentry/d_alias to hlist
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 44acb5b29ae4..015586f1ffc6 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -218,7 +218,7 @@ static void __d_free(struct rcu_head *head)
218{ 218{
219 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); 219 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
220 220
221 WARN_ON(!list_empty(&dentry->d_alias)); 221 WARN_ON(!hlist_unhashed(&dentry->d_alias));
222 if (dname_external(dentry)) 222 if (dname_external(dentry))
223 kfree(dentry->d_name.name); 223 kfree(dentry->d_name.name);
224 kmem_cache_free(dentry_cache, dentry); 224 kmem_cache_free(dentry_cache, dentry);
@@ -267,7 +267,7 @@ static void dentry_iput(struct dentry * dentry)
267 struct inode *inode = dentry->d_inode; 267 struct inode *inode = dentry->d_inode;
268 if (inode) { 268 if (inode) {
269 dentry->d_inode = NULL; 269 dentry->d_inode = NULL;
270 list_del_init(&dentry->d_alias); 270 hlist_del_init(&dentry->d_alias);
271 spin_unlock(&dentry->d_lock); 271 spin_unlock(&dentry->d_lock);
272 spin_unlock(&inode->i_lock); 272 spin_unlock(&inode->i_lock);
273 if (!inode->i_nlink) 273 if (!inode->i_nlink)
@@ -291,7 +291,7 @@ static void dentry_unlink_inode(struct dentry * dentry)
291{ 291{
292 struct inode *inode = dentry->d_inode; 292 struct inode *inode = dentry->d_inode;
293 dentry->d_inode = NULL; 293 dentry->d_inode = NULL;
294 list_del_init(&dentry->d_alias); 294 hlist_del_init(&dentry->d_alias);
295 dentry_rcuwalk_barrier(dentry); 295 dentry_rcuwalk_barrier(dentry);
296 spin_unlock(&dentry->d_lock); 296 spin_unlock(&dentry->d_lock);
297 spin_unlock(&inode->i_lock); 297 spin_unlock(&inode->i_lock);
@@ -699,10 +699,11 @@ EXPORT_SYMBOL(dget_parent);
699static struct dentry *__d_find_alias(struct inode *inode, int want_discon) 699static struct dentry *__d_find_alias(struct inode *inode, int want_discon)
700{ 700{
701 struct dentry *alias, *discon_alias; 701 struct dentry *alias, *discon_alias;
702 struct hlist_node *p;
702 703
703again: 704again:
704 discon_alias = NULL; 705 discon_alias = NULL;
705 list_for_each_entry(alias, &inode->i_dentry, d_alias) { 706 hlist_for_each_entry(alias, p, &inode->i_dentry, d_alias) {
706 spin_lock(&alias->d_lock); 707 spin_lock(&alias->d_lock);
707 if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { 708 if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) {
708 if (IS_ROOT(alias) && 709 if (IS_ROOT(alias) &&
@@ -737,7 +738,7 @@ struct dentry *d_find_alias(struct inode *inode)
737{ 738{
738 struct dentry *de = NULL; 739 struct dentry *de = NULL;
739 740
740 if (!list_empty(&inode->i_dentry)) { 741 if (!hlist_empty(&inode->i_dentry)) {
741 spin_lock(&inode->i_lock); 742 spin_lock(&inode->i_lock);
742 de = __d_find_alias(inode, 0); 743 de = __d_find_alias(inode, 0);
743 spin_unlock(&inode->i_lock); 744 spin_unlock(&inode->i_lock);
@@ -753,9 +754,10 @@ EXPORT_SYMBOL(d_find_alias);
753void d_prune_aliases(struct inode *inode) 754void d_prune_aliases(struct inode *inode)
754{ 755{
755 struct dentry *dentry; 756 struct dentry *dentry;
757 struct hlist_node *p;
756restart: 758restart:
757 spin_lock(&inode->i_lock); 759 spin_lock(&inode->i_lock);
758 list_for_each_entry(dentry, &inode->i_dentry, d_alias) { 760 hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
759 spin_lock(&dentry->d_lock); 761 spin_lock(&dentry->d_lock);
760 if (!dentry->d_count) { 762 if (!dentry->d_count) {
761 __dget_dlock(dentry); 763 __dget_dlock(dentry);
@@ -977,7 +979,7 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
977 inode = dentry->d_inode; 979 inode = dentry->d_inode;
978 if (inode) { 980 if (inode) {
979 dentry->d_inode = NULL; 981 dentry->d_inode = NULL;
980 list_del_init(&dentry->d_alias); 982 hlist_del_init(&dentry->d_alias);
981 if (dentry->d_op && dentry->d_op->d_iput) 983 if (dentry->d_op && dentry->d_op->d_iput)
982 dentry->d_op->d_iput(dentry, inode); 984 dentry->d_op->d_iput(dentry, inode);
983 else 985 else
@@ -1312,7 +1314,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
1312 INIT_HLIST_BL_NODE(&dentry->d_hash); 1314 INIT_HLIST_BL_NODE(&dentry->d_hash);
1313 INIT_LIST_HEAD(&dentry->d_lru); 1315 INIT_LIST_HEAD(&dentry->d_lru);
1314 INIT_LIST_HEAD(&dentry->d_subdirs); 1316 INIT_LIST_HEAD(&dentry->d_subdirs);
1315 INIT_LIST_HEAD(&dentry->d_alias); 1317 INIT_HLIST_NODE(&dentry->d_alias);
1316 INIT_LIST_HEAD(&dentry->d_u.d_child); 1318 INIT_LIST_HEAD(&dentry->d_u.d_child);
1317 d_set_d_op(dentry, dentry->d_sb->s_d_op); 1319 d_set_d_op(dentry, dentry->d_sb->s_d_op);
1318 1320
@@ -1400,7 +1402,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
1400 if (inode) { 1402 if (inode) {
1401 if (unlikely(IS_AUTOMOUNT(inode))) 1403 if (unlikely(IS_AUTOMOUNT(inode)))
1402 dentry->d_flags |= DCACHE_NEED_AUTOMOUNT; 1404 dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
1403 list_add(&dentry->d_alias, &inode->i_dentry); 1405 hlist_add_head(&dentry->d_alias, &inode->i_dentry);
1404 } 1406 }
1405 dentry->d_inode = inode; 1407 dentry->d_inode = inode;
1406 dentry_rcuwalk_barrier(dentry); 1408 dentry_rcuwalk_barrier(dentry);
@@ -1425,7 +1427,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
1425 1427
1426void d_instantiate(struct dentry *entry, struct inode * inode) 1428void d_instantiate(struct dentry *entry, struct inode * inode)
1427{ 1429{
1428 BUG_ON(!list_empty(&entry->d_alias)); 1430 BUG_ON(!hlist_unhashed(&entry->d_alias));
1429 if (inode) 1431 if (inode)
1430 spin_lock(&inode->i_lock); 1432 spin_lock(&inode->i_lock);
1431 __d_instantiate(entry, inode); 1433 __d_instantiate(entry, inode);
@@ -1458,13 +1460,14 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
1458 int len = entry->d_name.len; 1460 int len = entry->d_name.len;
1459 const char *name = entry->d_name.name; 1461 const char *name = entry->d_name.name;
1460 unsigned int hash = entry->d_name.hash; 1462 unsigned int hash = entry->d_name.hash;
1463 struct hlist_node *p;
1461 1464
1462 if (!inode) { 1465 if (!inode) {
1463 __d_instantiate(entry, NULL); 1466 __d_instantiate(entry, NULL);
1464 return NULL; 1467 return NULL;
1465 } 1468 }
1466 1469
1467 list_for_each_entry(alias, &inode->i_dentry, d_alias) { 1470 hlist_for_each_entry(alias, p, &inode->i_dentry, d_alias) {
1468 /* 1471 /*
1469 * Don't need alias->d_lock here, because aliases with 1472 * Don't need alias->d_lock here, because aliases with
1470 * d_parent == entry->d_parent are not subject to name or 1473 * d_parent == entry->d_parent are not subject to name or
@@ -1490,7 +1493,7 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode)
1490{ 1493{
1491 struct dentry *result; 1494 struct dentry *result;
1492 1495
1493 BUG_ON(!list_empty(&entry->d_alias)); 1496 BUG_ON(!hlist_unhashed(&entry->d_alias));
1494 1497
1495 if (inode) 1498 if (inode)
1496 spin_lock(&inode->i_lock); 1499 spin_lock(&inode->i_lock);
@@ -1531,9 +1534,9 @@ static struct dentry * __d_find_any_alias(struct inode *inode)
1531{ 1534{
1532 struct dentry *alias; 1535 struct dentry *alias;
1533 1536
1534 if (list_empty(&inode->i_dentry)) 1537 if (hlist_empty(&inode->i_dentry))
1535 return NULL; 1538 return NULL;
1536 alias = list_first_entry(&inode->i_dentry, struct dentry, d_alias); 1539 alias = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
1537 __dget(alias); 1540 __dget(alias);
1538 return alias; 1541 return alias;
1539} 1542}
@@ -1607,7 +1610,7 @@ struct dentry *d_obtain_alias(struct inode *inode)
1607 spin_lock(&tmp->d_lock); 1610 spin_lock(&tmp->d_lock);
1608 tmp->d_inode = inode; 1611 tmp->d_inode = inode;
1609 tmp->d_flags |= DCACHE_DISCONNECTED; 1612 tmp->d_flags |= DCACHE_DISCONNECTED;
1610 list_add(&tmp->d_alias, &inode->i_dentry); 1613 hlist_add_head(&tmp->d_alias, &inode->i_dentry);
1611 hlist_bl_lock(&tmp->d_sb->s_anon); 1614 hlist_bl_lock(&tmp->d_sb->s_anon);
1612 hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon); 1615 hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon);
1613 hlist_bl_unlock(&tmp->d_sb->s_anon); 1616 hlist_bl_unlock(&tmp->d_sb->s_anon);