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

Configure Feed

Select the types of activity you want to include in your feed.

for_each_alias(): helper macro for iterating through dentries of given inode

Most of the places using d_alias are loops iterating through all aliases for
given inode; introduce a helper macro (for_each_alias(dentry, inode))
and convert open-coded instances of such loop to it.

They are easier to read that way and it reduces the noise on the next steps.

You _must_ hold inode->i_lock over that thing.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 408d8af0 7aaa8047

+25 -11
+10
Documentation/filesystems/porting.rst
··· 1361 1361 1362 1362 However, if the string is freely accessible for the duration of inode's 1363 1363 lifetime, consider using inode_set_cached_link() instead. 1364 + 1365 + --- 1366 + 1367 + **recommended** 1368 + 1369 + If you really need to iterate through dentries for given inode, use 1370 + for_each_alias(dentry, inode) instead of hlist_for_each_entry; better 1371 + yet, see if any of the exported primitives could be used instead of 1372 + the entire loop. You still need to hold ->i_lock of the inode over 1373 + either form of manual loop.
+1 -1
fs/affs/amigaffs.c
··· 126 126 { 127 127 struct dentry *dentry; 128 128 spin_lock(&inode->i_lock); 129 - hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { 129 + for_each_alias(dentry, inode) { 130 130 if (entry_ino == (u32)(long)dentry->d_fsdata) { 131 131 dentry->d_fsdata = (void *)inode->i_ino; 132 132 break;
+1 -1
fs/ceph/mds_client.c
··· 4614 4614 goto out_unlock; 4615 4615 } 4616 4616 4617 - hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 4617 + for_each_alias(alias, inode) { 4618 4618 spin_lock(&alias->d_lock); 4619 4619 if (!d_unhashed(alias) && 4620 4620 (ceph_dentry(alias)->flags & CEPH_DENTRY_PRIMARY_LINK)) {
+3 -3
fs/dcache.c
··· 790 790 struct dentry *de; 791 791 792 792 spin_lock(&inode->i_lock); 793 - hlist_for_each_entry(de, &inode->i_dentry, d_u.d_alias) { 793 + for_each_alias(de, inode) { 794 794 spin_lock(&de->d_lock); 795 795 de->d_flags |= DCACHE_DONTCACHE; 796 796 spin_unlock(&de->d_lock); ··· 1040 1040 if (S_ISDIR(inode->i_mode)) 1041 1041 return __d_find_any_alias(inode); 1042 1042 1043 - hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 1043 + for_each_alias(alias, inode) { 1044 1044 spin_lock(&alias->d_lock); 1045 1045 if (!d_unhashed(alias)) { 1046 1046 dget_dlock(alias); ··· 1133 1133 struct dentry *dentry; 1134 1134 1135 1135 spin_lock(&inode->i_lock); 1136 - hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) 1136 + for_each_alias(dentry, inode) 1137 1137 d_dispose_if_unused(dentry, &dispose); 1138 1138 spin_unlock(&inode->i_lock); 1139 1139 shrink_dentry_list(&dispose);
+1 -1
fs/exportfs/expfs.c
··· 52 52 53 53 inode = result->d_inode; 54 54 spin_lock(&inode->i_lock); 55 - hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { 55 + for_each_alias(dentry, inode) { 56 56 dget(dentry); 57 57 spin_unlock(&inode->i_lock); 58 58 if (toput)
+1 -1
fs/nfs/dir.c
··· 1471 1471 struct dentry *alias; 1472 1472 struct inode *dir; 1473 1473 1474 - hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 1474 + for_each_alias(alias, inode) { 1475 1475 spin_lock(&alias->d_lock); 1476 1476 dir = d_inode_rcu(alias->d_parent); 1477 1477 if (!dir ||
+1 -1
fs/notify/fsnotify.c
··· 76 76 spin_lock(&inode->i_lock); 77 77 /* run all of the dentries associated with this inode. Since this is a 78 78 * directory, there damn well better only be one item on this list */ 79 - hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 79 + for_each_alias(alias, inode) { 80 80 struct dentry *child; 81 81 82 82 /* run all of the children of the original inode and fix their
+1 -1
fs/ocfs2/dcache.c
··· 145 145 struct dentry *dentry; 146 146 147 147 spin_lock(&inode->i_lock); 148 - hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { 148 + for_each_alias(dentry, inode) { 149 149 spin_lock(&dentry->d_lock); 150 150 if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) { 151 151 trace_ocfs2_find_local_alias(dentry->d_name.len,
+1 -1
fs/overlayfs/dir.c
··· 904 904 905 905 /* Try to find another, hashed alias */ 906 906 spin_lock(&inode->i_lock); 907 - hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 907 + for_each_alias(alias, inode) { 908 908 if (alias != dentry && !d_unhashed(alias)) 909 909 break; 910 910 }
+1 -1
fs/smb/client/inode.c
··· 1595 1595 struct dentry *dentry; 1596 1596 1597 1597 spin_lock(&inode->i_lock); 1598 - hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { 1598 + for_each_alias(dentry, inode) { 1599 1599 if (!d_unhashed(dentry) || IS_ROOT(dentry)) { 1600 1600 spin_unlock(&inode->i_lock); 1601 1601 return true;
+4
include/linux/dcache.h
··· 615 615 struct dentry *d_make_persistent(struct dentry *, struct inode *); 616 616 void d_make_discardable(struct dentry *dentry); 617 617 618 + /* inode->i_lock must be held over that */ 619 + #define for_each_alias(dentry, inode) \ 620 + hlist_for_each_entry(dentry, &(inode)->i_dentry, d_u.d_alias) 621 + 618 622 #endif /* __LINUX_DCACHE_H */