aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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
parent9f713878f22e0b2d34d62df0ca55f65166375634 (diff)
vfs: switch i_dentry/d_alias to hlist
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/affs/amigaffs.c3
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/cifs/inode.c5
-rw-r--r--fs/dcache.c33
-rw-r--r--fs/exportfs/expfs.c3
-rw-r--r--fs/ext4/fsync.c2
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/inode.c2
-rw-r--r--fs/nfs/getroot.c2
-rw-r--r--fs/notify/fsnotify.c3
-rw-r--r--fs/ocfs2/dcache.c3
11 files changed, 34 insertions, 26 deletions
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 843cdc99480..eb82ee53ee0 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -125,8 +125,9 @@ static void
125affs_fix_dcache(struct inode *inode, u32 entry_ino) 125affs_fix_dcache(struct inode *inode, u32 entry_ino)
126{ 126{
127 struct dentry *dentry; 127 struct dentry *dentry;
128 struct hlist_node *p;
128 spin_lock(&inode->i_lock); 129 spin_lock(&inode->i_lock);
129 list_for_each_entry(dentry, &inode->i_dentry, d_alias) { 130 hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
130 if (entry_ino == (u32)(long)dentry->d_fsdata) { 131 if (entry_ino == (u32)(long)dentry->d_fsdata) {
131 dentry->d_fsdata = (void *)inode->i_ino; 132 dentry->d_fsdata = (void *)inode->i_ino;
132 break; 133 break;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a7d1921ac76..a101572f1ce 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6987,7 +6987,7 @@ void btrfs_destroy_inode(struct inode *inode)
6987 struct btrfs_ordered_extent *ordered; 6987 struct btrfs_ordered_extent *ordered;
6988 struct btrfs_root *root = BTRFS_I(inode)->root; 6988 struct btrfs_root *root = BTRFS_I(inode)->root;
6989 6989
6990 WARN_ON(!list_empty(&inode->i_dentry)); 6990 WARN_ON(!hlist_empty(&inode->i_dentry));
6991 WARN_ON(inode->i_data.nrpages); 6991 WARN_ON(inode->i_data.nrpages);
6992 WARN_ON(BTRFS_I(inode)->outstanding_extents); 6992 WARN_ON(BTRFS_I(inode)->outstanding_extents);
6993 WARN_ON(BTRFS_I(inode)->reserved_extents); 6993 WARN_ON(BTRFS_I(inode)->reserved_extents);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 745da3d0653..8e8bb49112f 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -800,7 +800,7 @@ cifs_find_inode(struct inode *inode, void *opaque)
800 return 0; 800 return 0;
801 801
802 /* if it's not a directory or has no dentries, then flag it */ 802 /* if it's not a directory or has no dentries, then flag it */
803 if (S_ISDIR(inode->i_mode) && !list_empty(&inode->i_dentry)) 803 if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry))
804 fattr->cf_flags |= CIFS_FATTR_INO_COLLISION; 804 fattr->cf_flags |= CIFS_FATTR_INO_COLLISION;
805 805
806 return 1; 806 return 1;
@@ -825,9 +825,10 @@ static bool
825inode_has_hashed_dentries(struct inode *inode) 825inode_has_hashed_dentries(struct inode *inode)
826{ 826{
827 struct dentry *dentry; 827 struct dentry *dentry;
828 struct hlist_node *p;
828 829
829 spin_lock(&inode->i_lock); 830 spin_lock(&inode->i_lock);
830 list_for_each_entry(dentry, &inode->i_dentry, d_alias) { 831 hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
831 if (!d_unhashed(dentry) || IS_ROOT(dentry)) { 832 if (!d_unhashed(dentry) || IS_ROOT(dentry)) {
832 spin_unlock(&inode->i_lock); 833 spin_unlock(&inode->i_lock);
833 return true; 834 return true;
diff --git a/fs/dcache.c b/fs/dcache.c
index 44acb5b29ae..015586f1ffc 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);
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index b0201ca6e9c..b42063cf1b2 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -44,13 +44,14 @@ find_acceptable_alias(struct dentry *result,
44{ 44{
45 struct dentry *dentry, *toput = NULL; 45 struct dentry *dentry, *toput = NULL;
46 struct inode *inode; 46 struct inode *inode;
47 struct hlist_node *p;
47 48
48 if (acceptable(context, result)) 49 if (acceptable(context, result))
49 return result; 50 return result;
50 51
51 inode = result->d_inode; 52 inode = result->d_inode;
52 spin_lock(&inode->i_lock); 53 spin_lock(&inode->i_lock);
53 list_for_each_entry(dentry, &inode->i_dentry, d_alias) { 54 hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
54 dget(dentry); 55 dget(dentry);
55 spin_unlock(&inode->i_lock); 56 spin_unlock(&inode->i_lock);
56 if (toput) 57 if (toput)
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 4359a4d3006..2a1dcea4f12 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -225,7 +225,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
225 225
226 if (!journal) { 226 if (!journal) {
227 ret = __sync_inode(inode, datasync); 227 ret = __sync_inode(inode, datasync);
228 if (!ret && !list_empty(&inode->i_dentry)) 228 if (!ret && !hlist_empty(&inode->i_dentry))
229 ret = ext4_sync_parent(inode); 229 ret = ext4_sync_parent(inode);
230 goto out; 230 goto out;
231 } 231 }
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 334e0b18a01..f7543f72897 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -249,7 +249,7 @@ static struct dentry *fuse_d_add_directory(struct dentry *entry,
249 /* This tries to shrink the subtree below alias */ 249 /* This tries to shrink the subtree below alias */
250 fuse_invalidate_entry(alias); 250 fuse_invalidate_entry(alias);
251 dput(alias); 251 dput(alias);
252 if (!list_empty(&inode->i_dentry)) 252 if (!hlist_empty(&inode->i_dentry))
253 return ERR_PTR(-EBUSY); 253 return ERR_PTR(-EBUSY);
254 } else { 254 } else {
255 dput(alias); 255 dput(alias);
diff --git a/fs/inode.c b/fs/inode.c
index c99163b1b31..775cbabd4fa 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -182,7 +182,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
182 } 182 }
183 inode->i_private = NULL; 183 inode->i_private = NULL;
184 inode->i_mapping = mapping; 184 inode->i_mapping = mapping;
185 INIT_LIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */ 185 INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */
186#ifdef CONFIG_FS_POSIX_ACL 186#ifdef CONFIG_FS_POSIX_ACL
187 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED; 187 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
188#endif 188#endif
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index 8abfb19bd3a..a67990f90bd 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -62,7 +62,7 @@ static int nfs_superblock_set_dummy_root(struct super_block *sb, struct inode *i
62 */ 62 */
63 spin_lock(&sb->s_root->d_inode->i_lock); 63 spin_lock(&sb->s_root->d_inode->i_lock);
64 spin_lock(&sb->s_root->d_lock); 64 spin_lock(&sb->s_root->d_lock);
65 list_del_init(&sb->s_root->d_alias); 65 hlist_del_init(&sb->s_root->d_alias);
66 spin_unlock(&sb->s_root->d_lock); 66 spin_unlock(&sb->s_root->d_lock);
67 spin_unlock(&sb->s_root->d_inode->i_lock); 67 spin_unlock(&sb->s_root->d_inode->i_lock);
68 } 68 }
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index b39c5c161ad..6baadb5a843 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -52,6 +52,7 @@ void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
52void __fsnotify_update_child_dentry_flags(struct inode *inode) 52void __fsnotify_update_child_dentry_flags(struct inode *inode)
53{ 53{
54 struct dentry *alias; 54 struct dentry *alias;
55 struct hlist_node *p;
55 int watched; 56 int watched;
56 57
57 if (!S_ISDIR(inode->i_mode)) 58 if (!S_ISDIR(inode->i_mode))
@@ -63,7 +64,7 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
63 spin_lock(&inode->i_lock); 64 spin_lock(&inode->i_lock);
64 /* run all of the dentries associated with this inode. Since this is a 65 /* run all of the dentries associated with this inode. Since this is a
65 * directory, there damn well better only be one item on this list */ 66 * directory, there damn well better only be one item on this list */
66 list_for_each_entry(alias, &inode->i_dentry, d_alias) { 67 hlist_for_each_entry(alias, p, &inode->i_dentry, d_alias) {
67 struct dentry *child; 68 struct dentry *child;
68 69
69 /* run all of the children of the original inode and fix their 70 /* run all of the children of the original inode and fix their
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index a40edc1e1d8..af4488268e4 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -170,10 +170,11 @@ struct dentry *ocfs2_find_local_alias(struct inode *inode,
170 u64 parent_blkno, 170 u64 parent_blkno,
171 int skip_unhashed) 171 int skip_unhashed)
172{ 172{
173 struct hlist_node *p;
173 struct dentry *dentry; 174 struct dentry *dentry;
174 175
175 spin_lock(&inode->i_lock); 176 spin_lock(&inode->i_lock);
176 list_for_each_entry(dentry, &inode->i_dentry, d_alias) { 177 hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
177 spin_lock(&dentry->d_lock); 178 spin_lock(&dentry->d_lock);
178 if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) { 179 if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) {
179 trace_ocfs2_find_local_alias(dentry->d_name.len, 180 trace_ocfs2_find_local_alias(dentry->d_name.len,