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

Don't pass inode to ->d_hash() and ->d_compare()

Instances either don't look at it at all (the majority of cases) or
only want it to find the superblock (which can be had as dentry->d_sb).
A few cases that want more are actually safe with dentry->d_inode -
the only precaution needed is the check that it hadn't been replaced with
NULL by rmdir() or by overwriting rename(), which case should be simply
treated as cache miss.

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

authored by

Linus Torvalds and committed by
Al Viro
da53be12 642b704c

+108 -165
+2 -4
Documentation/filesystems/Locking
··· 11 11 prototypes: 12 12 int (*d_revalidate)(struct dentry *, unsigned int); 13 13 int (*d_weak_revalidate)(struct dentry *, unsigned int); 14 - int (*d_hash)(const struct dentry *, const struct inode *, 15 - struct qstr *); 16 - int (*d_compare)(const struct dentry *, const struct inode *, 17 - const struct dentry *, const struct inode *, 14 + int (*d_hash)(const struct dentry *, struct qstr *); 15 + int (*d_compare)(const struct dentry *, const struct dentry *, 18 16 unsigned int, const char *, const struct qstr *); 19 17 int (*d_delete)(struct dentry *); 20 18 void (*d_release)(struct dentry *);
+8 -11
Documentation/filesystems/vfs.txt
··· 901 901 struct dentry_operations { 902 902 int (*d_revalidate)(struct dentry *, unsigned int); 903 903 int (*d_weak_revalidate)(struct dentry *, unsigned int); 904 - int (*d_hash)(const struct dentry *, const struct inode *, 905 - struct qstr *); 906 - int (*d_compare)(const struct dentry *, const struct inode *, 907 - const struct dentry *, const struct inode *, 904 + int (*d_hash)(const struct dentry *, struct qstr *); 905 + int (*d_compare)(const struct dentry *, const struct dentry *, 908 906 unsigned int, const char *, const struct qstr *); 909 907 int (*d_delete)(const struct dentry *); 910 908 void (*d_release)(struct dentry *); ··· 947 949 948 950 d_hash: called when the VFS adds a dentry to the hash table. The first 949 951 dentry passed to d_hash is the parent directory that the name is 950 - to be hashed into. The inode is the dentry's inode. 952 + to be hashed into. 951 953 952 954 Same locking and synchronisation rules as d_compare regarding 953 955 what is safe to dereference etc. 954 956 955 957 d_compare: called to compare a dentry name with a given name. The first 956 958 dentry is the parent of the dentry to be compared, the second is 957 - the parent's inode, then the dentry and inode (may be NULL) of the 958 - child dentry. len and name string are properties of the dentry to be 959 - compared. qstr is the name to compare it with. 959 + the child dentry. len and name string are properties of the dentry 960 + to be compared. qstr is the name to compare it with. 960 961 961 962 Must be constant and idempotent, and should not take locks if 962 - possible, and should not or store into the dentry or inodes. 963 - Should not dereference pointers outside the dentry or inodes without 963 + possible, and should not or store into the dentry. 964 + Should not dereference pointers outside the dentry without 964 965 lots of care (eg. d_parent, d_inode, d_name should not be used). 965 966 966 967 However, our vfsmount is pinned, and RCU held, so the dentries and 967 968 inodes won't disappear, neither will our sb or filesystem module. 968 - ->i_sb and ->d_sb may be used. 969 + ->d_sb may be used. 969 970 970 971 It is a tricky calling convention because it needs to be called under 971 972 "rcu-walk", ie. without any locks or references on things.
+2 -4
fs/adfs/dir.c
··· 191 191 }; 192 192 193 193 static int 194 - adfs_hash(const struct dentry *parent, const struct inode *inode, 195 - struct qstr *qstr) 194 + adfs_hash(const struct dentry *parent, struct qstr *qstr) 196 195 { 197 196 const unsigned int name_len = ADFS_SB(parent->d_sb)->s_namelen; 198 197 const unsigned char *name; ··· 227 228 * requirements of the underlying filesystem. 228 229 */ 229 230 static int 230 - adfs_compare(const struct dentry *parent, const struct inode *pinode, 231 - const struct dentry *dentry, const struct inode *inode, 231 + adfs_compare(const struct dentry *parent, const struct dentry *dentry, 232 232 unsigned int len, const char *str, const struct qstr *name) 233 233 { 234 234 int i;
+8 -18
fs/affs/namei.c
··· 13 13 typedef int (*toupper_t)(int); 14 14 15 15 static int affs_toupper(int ch); 16 - static int affs_hash_dentry(const struct dentry *, 17 - const struct inode *, struct qstr *); 18 - static int affs_compare_dentry(const struct dentry *parent, 19 - const struct inode *pinode, 20 - const struct dentry *dentry, const struct inode *inode, 16 + static int affs_hash_dentry(const struct dentry *, struct qstr *); 17 + static int affs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 21 18 unsigned int len, const char *str, const struct qstr *name); 22 19 static int affs_intl_toupper(int ch); 23 - static int affs_intl_hash_dentry(const struct dentry *, 24 - const struct inode *, struct qstr *); 25 - static int affs_intl_compare_dentry(const struct dentry *parent, 26 - const struct inode *pinode, 27 - const struct dentry *dentry, const struct inode *inode, 20 + static int affs_intl_hash_dentry(const struct dentry *, struct qstr *); 21 + static int affs_intl_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 28 22 unsigned int len, const char *str, const struct qstr *name); 29 23 30 24 const struct dentry_operations affs_dentry_operations = { ··· 80 86 } 81 87 82 88 static int 83 - affs_hash_dentry(const struct dentry *dentry, const struct inode *inode, 84 - struct qstr *qstr) 89 + affs_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 85 90 { 86 91 return __affs_hash_dentry(qstr, affs_toupper); 87 92 } 88 93 static int 89 - affs_intl_hash_dentry(const struct dentry *dentry, const struct inode *inode, 90 - struct qstr *qstr) 94 + affs_intl_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 91 95 { 92 96 return __affs_hash_dentry(qstr, affs_intl_toupper); 93 97 } ··· 123 131 } 124 132 125 133 static int 126 - affs_compare_dentry(const struct dentry *parent, const struct inode *pinode, 127 - const struct dentry *dentry, const struct inode *inode, 134 + affs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 128 135 unsigned int len, const char *str, const struct qstr *name) 129 136 { 130 137 return __affs_compare_dentry(len, str, name, affs_toupper); 131 138 } 132 139 static int 133 - affs_intl_compare_dentry(const struct dentry *parent,const struct inode *pinode, 134 - const struct dentry *dentry, const struct inode *inode, 140 + affs_intl_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 135 141 unsigned int len, const char *str, const struct qstr *name) 136 142 { 137 143 return __affs_compare_dentry(len, str, name, affs_intl_toupper);
+3 -6
fs/cifs/dir.c
··· 822 822 /* d_delete: cifs_d_delete, */ /* not needed except for debugging */ 823 823 }; 824 824 825 - static int cifs_ci_hash(const struct dentry *dentry, const struct inode *inode, 826 - struct qstr *q) 825 + static int cifs_ci_hash(const struct dentry *dentry, struct qstr *q) 827 826 { 828 827 struct nls_table *codepage = CIFS_SB(dentry->d_sb)->local_nls; 829 828 unsigned long hash; ··· 837 838 return 0; 838 839 } 839 840 840 - static int cifs_ci_compare(const struct dentry *parent, 841 - const struct inode *pinode, 842 - const struct dentry *dentry, const struct inode *inode, 841 + static int cifs_ci_compare(const struct dentry *parent, const struct dentry *dentry, 843 842 unsigned int len, const char *str, const struct qstr *name) 844 843 { 845 - struct nls_table *codepage = CIFS_SB(pinode->i_sb)->local_nls; 844 + struct nls_table *codepage = CIFS_SB(parent->d_sb)->local_nls; 846 845 847 846 if ((name->len == len) && 848 847 (nls_strnicmp(codepage, name->name, str, len) == 0))
+10 -17
fs/dcache.c
··· 1723 1723 * Do the slow-case of the dentry name compare. 1724 1724 * 1725 1725 * Unlike the dentry_cmp() function, we need to atomically 1726 - * load the name, length and inode information, so that the 1726 + * load the name and length information, so that the 1727 1727 * filesystem can rely on them, and can use the 'name' and 1728 1728 * 'len' information without worrying about walking off the 1729 1729 * end of memory etc. ··· 1741 1741 1742 1742 static noinline enum slow_d_compare slow_dentry_cmp( 1743 1743 const struct dentry *parent, 1744 - struct inode *inode, 1745 1744 struct dentry *dentry, 1746 1745 unsigned int seq, 1747 1746 const struct qstr *name) 1748 1747 { 1749 1748 int tlen = dentry->d_name.len; 1750 1749 const char *tname = dentry->d_name.name; 1751 - struct inode *i = dentry->d_inode; 1752 1750 1753 1751 if (read_seqcount_retry(&dentry->d_seq, seq)) { 1754 1752 cpu_relax(); 1755 1753 return D_COMP_SEQRETRY; 1756 1754 } 1757 - if (parent->d_op->d_compare(parent, inode, 1758 - dentry, i, 1759 - tlen, tname, name)) 1755 + if (parent->d_op->d_compare(parent, dentry, tlen, tname, name)) 1760 1756 return D_COMP_NOMATCH; 1761 1757 return D_COMP_OK; 1762 1758 } ··· 1762 1766 * @parent: parent dentry 1763 1767 * @name: qstr of name we wish to find 1764 1768 * @seqp: returns d_seq value at the point where the dentry was found 1765 - * @inode: returns dentry->d_inode when the inode was found valid. 1766 1769 * Returns: dentry, or NULL 1767 1770 * 1768 1771 * __d_lookup_rcu is the dcache lookup function for rcu-walk name ··· 1788 1793 */ 1789 1794 struct dentry *__d_lookup_rcu(const struct dentry *parent, 1790 1795 const struct qstr *name, 1791 - unsigned *seqp, struct inode *inode) 1796 + unsigned *seqp) 1792 1797 { 1793 1798 u64 hashlen = name->hash_len; 1794 1799 const unsigned char *str = name->name; ··· 1822 1827 seqretry: 1823 1828 /* 1824 1829 * The dentry sequence count protects us from concurrent 1825 - * renames, and thus protects inode, parent and name fields. 1830 + * renames, and thus protects parent and name fields. 1826 1831 * 1827 1832 * The caller must perform a seqcount check in order 1828 - * to do anything useful with the returned dentry, 1829 - * including using the 'd_inode' pointer. 1833 + * to do anything useful with the returned dentry. 1830 1834 * 1831 1835 * NOTE! We do a "raw" seqcount_begin here. That means that 1832 1836 * we don't wait for the sequence count to stabilize if it ··· 1839 1845 continue; 1840 1846 if (d_unhashed(dentry)) 1841 1847 continue; 1842 - *seqp = seq; 1843 1848 1844 1849 if (unlikely(parent->d_flags & DCACHE_OP_COMPARE)) { 1845 1850 if (dentry->d_name.hash != hashlen_hash(hashlen)) 1846 1851 continue; 1847 - switch (slow_dentry_cmp(parent, inode, dentry, seq, name)) { 1852 + *seqp = seq; 1853 + switch (slow_dentry_cmp(parent, dentry, seq, name)) { 1848 1854 case D_COMP_OK: 1849 1855 return dentry; 1850 1856 case D_COMP_NOMATCH: ··· 1856 1862 1857 1863 if (dentry->d_name.hash_len != hashlen) 1858 1864 continue; 1865 + *seqp = seq; 1859 1866 if (!dentry_cmp(dentry, str, hashlen_len(hashlen))) 1860 1867 return dentry; 1861 1868 } ··· 1954 1959 if (parent->d_flags & DCACHE_OP_COMPARE) { 1955 1960 int tlen = dentry->d_name.len; 1956 1961 const char *tname = dentry->d_name.name; 1957 - if (parent->d_op->d_compare(parent, parent->d_inode, 1958 - dentry, dentry->d_inode, 1959 - tlen, tname, name)) 1962 + if (parent->d_op->d_compare(parent, dentry, tlen, tname, name)) 1960 1963 goto next; 1961 1964 } else { 1962 1965 if (dentry->d_name.len != len) ··· 1991 1998 */ 1992 1999 name->hash = full_name_hash(name->name, name->len); 1993 2000 if (dir->d_flags & DCACHE_OP_HASH) { 1994 - int err = dir->d_op->d_hash(dir, dir->d_inode, name); 2001 + int err = dir->d_op->d_hash(dir, name); 1995 2002 if (unlikely(err < 0)) 1996 2003 return ERR_PTR(err); 1997 2004 }
+4 -5
fs/efivarfs/super.c
··· 45 45 * So we need to perform a case-sensitive match on part 1 and a 46 46 * case-insensitive match on part 2. 47 47 */ 48 - static int efivarfs_d_compare(const struct dentry *parent, const struct inode *pinode, 49 - const struct dentry *dentry, const struct inode *inode, 48 + static int efivarfs_d_compare(const struct dentry *parent, 49 + const struct dentry *dentry, 50 50 unsigned int len, const char *str, 51 51 const struct qstr *name) 52 52 { ··· 63 63 return strncasecmp(name->name + guid, str + guid, EFI_VARIABLE_GUID_LEN); 64 64 } 65 65 66 - static int efivarfs_d_hash(const struct dentry *dentry, 67 - const struct inode *inode, struct qstr *qstr) 66 + static int efivarfs_d_hash(const struct dentry *dentry, struct qstr *qstr) 68 67 { 69 68 unsigned long hash = init_name_hash(); 70 69 const unsigned char *s = qstr->name; ··· 107 108 q.name = name; 108 109 q.len = strlen(name); 109 110 110 - err = efivarfs_d_hash(NULL, NULL, &q); 111 + err = efivarfs_d_hash(NULL, &q); 111 112 if (err) 112 113 return ERR_PTR(err); 113 114
+2 -4
fs/fat/namei_msdos.c
··· 148 148 * that the existing dentry can be used. The msdos fs routines will 149 149 * return ENOENT or EINVAL as appropriate. 150 150 */ 151 - static int msdos_hash(const struct dentry *dentry, const struct inode *inode, 152 - struct qstr *qstr) 151 + static int msdos_hash(const struct dentry *dentry, struct qstr *qstr) 153 152 { 154 153 struct fat_mount_options *options = &MSDOS_SB(dentry->d_sb)->options; 155 154 unsigned char msdos_name[MSDOS_NAME]; ··· 164 165 * Compare two msdos names. If either of the names are invalid, 165 166 * we fall back to doing the standard name comparison. 166 167 */ 167 - static int msdos_cmp(const struct dentry *parent, const struct inode *pinode, 168 - const struct dentry *dentry, const struct inode *inode, 168 + static int msdos_cmp(const struct dentry *parent, const struct dentry *dentry, 169 169 unsigned int len, const char *str, const struct qstr *name) 170 170 { 171 171 struct fat_mount_options *options = &MSDOS_SB(parent->d_sb)->options;
+4 -8
fs/fat/namei_vfat.c
··· 107 107 * that the existing dentry can be used. The vfat fs routines will 108 108 * return ENOENT or EINVAL as appropriate. 109 109 */ 110 - static int vfat_hash(const struct dentry *dentry, const struct inode *inode, 111 - struct qstr *qstr) 110 + static int vfat_hash(const struct dentry *dentry, struct qstr *qstr) 112 111 { 113 112 qstr->hash = full_name_hash(qstr->name, vfat_striptail_len(qstr)); 114 113 return 0; ··· 119 120 * that the existing dentry can be used. The vfat fs routines will 120 121 * return ENOENT or EINVAL as appropriate. 121 122 */ 122 - static int vfat_hashi(const struct dentry *dentry, const struct inode *inode, 123 - struct qstr *qstr) 123 + static int vfat_hashi(const struct dentry *dentry, struct qstr *qstr) 124 124 { 125 125 struct nls_table *t = MSDOS_SB(dentry->d_sb)->nls_io; 126 126 const unsigned char *name; ··· 140 142 /* 141 143 * Case insensitive compare of two vfat names. 142 144 */ 143 - static int vfat_cmpi(const struct dentry *parent, const struct inode *pinode, 144 - const struct dentry *dentry, const struct inode *inode, 145 + static int vfat_cmpi(const struct dentry *parent, const struct dentry *dentry, 145 146 unsigned int len, const char *str, const struct qstr *name) 146 147 { 147 148 struct nls_table *t = MSDOS_SB(parent->d_sb)->nls_io; ··· 159 162 /* 160 163 * Case sensitive compare of two vfat names. 161 164 */ 162 - static int vfat_cmp(const struct dentry *parent, const struct inode *pinode, 163 - const struct dentry *dentry, const struct inode *inode, 165 + static int vfat_cmp(const struct dentry *parent, const struct dentry *dentry, 164 166 unsigned int len, const char *str, const struct qstr *name) 165 167 { 166 168 unsigned int alen, blen;
+1 -2
fs/gfs2/dentry.c
··· 109 109 return 0; 110 110 } 111 111 112 - static int gfs2_dhash(const struct dentry *dentry, const struct inode *inode, 113 - struct qstr *str) 112 + static int gfs2_dhash(const struct dentry *dentry, struct qstr *str) 114 113 { 115 114 str->hash = gfs2_disk_hash(str->name, str->len); 116 115 return 0;
+2 -5
fs/hfs/hfs_fs.h
··· 229 229 /* string.c */ 230 230 extern const struct dentry_operations hfs_dentry_operations; 231 231 232 - extern int hfs_hash_dentry(const struct dentry *, const struct inode *, 233 - struct qstr *); 232 + extern int hfs_hash_dentry(const struct dentry *, struct qstr *); 234 233 extern int hfs_strcmp(const unsigned char *, unsigned int, 235 234 const unsigned char *, unsigned int); 236 - extern int hfs_compare_dentry(const struct dentry *parent, 237 - const struct inode *pinode, 238 - const struct dentry *dentry, const struct inode *inode, 235 + extern int hfs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 239 236 unsigned int len, const char *str, const struct qstr *name); 240 237 241 238 /* trans.c */
+2 -4
fs/hfs/string.c
··· 51 51 /* 52 52 * Hash a string to an integer in a case-independent way 53 53 */ 54 - int hfs_hash_dentry(const struct dentry *dentry, const struct inode *inode, 55 - struct qstr *this) 54 + int hfs_hash_dentry(const struct dentry *dentry, struct qstr *this) 56 55 { 57 56 const unsigned char *name = this->name; 58 57 unsigned int hash, len = this->len; ··· 92 93 * Test for equality of two strings in the HFS filename character ordering. 93 94 * return 1 on failure and 0 on success 94 95 */ 95 - int hfs_compare_dentry(const struct dentry *parent, const struct inode *pinode, 96 - const struct dentry *dentry, const struct inode *inode, 96 + int hfs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 97 97 unsigned int len, const char *str, const struct qstr *name) 98 98 { 99 99 const unsigned char *n1, *n2;
+2 -5
fs/hfsplus/hfsplus_fs.h
··· 495 495 const struct hfsplus_unistr *, char *, int *); 496 496 int hfsplus_asc2uni(struct super_block *, 497 497 struct hfsplus_unistr *, int, const char *, int); 498 - int hfsplus_hash_dentry(const struct dentry *dentry, 499 - const struct inode *inode, struct qstr *str); 500 - int hfsplus_compare_dentry(const struct dentry *parent, 501 - const struct inode *pinode, 502 - const struct dentry *dentry, const struct inode *inode, 498 + int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str); 499 + int hfsplus_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 503 500 unsigned int len, const char *str, const struct qstr *name); 504 501 505 502 /* wrapper.c */
+2 -5
fs/hfsplus/unicode.c
··· 334 334 * Composed unicode characters are decomposed and case-folding is performed 335 335 * if the appropriate bits are (un)set on the superblock. 336 336 */ 337 - int hfsplus_hash_dentry(const struct dentry *dentry, const struct inode *inode, 338 - struct qstr *str) 337 + int hfsplus_hash_dentry(const struct dentry *dentry, struct qstr *str) 339 338 { 340 339 struct super_block *sb = dentry->d_sb; 341 340 const char *astr; ··· 385 386 * Composed unicode characters are decomposed and case-folding is performed 386 387 * if the appropriate bits are (un)set on the superblock. 387 388 */ 388 - int hfsplus_compare_dentry(const struct dentry *parent, 389 - const struct inode *pinode, 390 - const struct dentry *dentry, const struct inode *inode, 389 + int hfsplus_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 391 390 unsigned int len, const char *str, const struct qstr *name) 392 391 { 393 392 struct super_block *sb = parent->d_sb;
+2 -5
fs/hpfs/dentry.c
··· 12 12 * Note: the dentry argument is the parent dentry. 13 13 */ 14 14 15 - static int hpfs_hash_dentry(const struct dentry *dentry, const struct inode *inode, 16 - struct qstr *qstr) 15 + static int hpfs_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 17 16 { 18 17 unsigned long hash; 19 18 int i; ··· 34 35 return 0; 35 36 } 36 37 37 - static int hpfs_compare_dentry(const struct dentry *parent, 38 - const struct inode *pinode, 39 - const struct dentry *dentry, const struct inode *inode, 38 + static int hpfs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 40 39 unsigned int len, const char *str, const struct qstr *name) 41 40 { 42 41 unsigned al = len;
+16 -32
fs/isofs/inode.c
··· 28 28 29 29 #define BEQUIET 30 30 31 - static int isofs_hashi(const struct dentry *parent, const struct inode *inode, 32 - struct qstr *qstr); 33 - static int isofs_hash(const struct dentry *parent, const struct inode *inode, 34 - struct qstr *qstr); 31 + static int isofs_hashi(const struct dentry *parent, struct qstr *qstr); 32 + static int isofs_hash(const struct dentry *parent, struct qstr *qstr); 35 33 static int isofs_dentry_cmpi(const struct dentry *parent, 36 - const struct inode *pinode, 37 - const struct dentry *dentry, const struct inode *inode, 34 + const struct dentry *dentry, 38 35 unsigned int len, const char *str, const struct qstr *name); 39 36 static int isofs_dentry_cmp(const struct dentry *parent, 40 - const struct inode *pinode, 41 - const struct dentry *dentry, const struct inode *inode, 37 + const struct dentry *dentry, 42 38 unsigned int len, const char *str, const struct qstr *name); 43 39 44 40 #ifdef CONFIG_JOLIET 45 - static int isofs_hashi_ms(const struct dentry *parent, const struct inode *inode, 46 - struct qstr *qstr); 47 - static int isofs_hash_ms(const struct dentry *parent, const struct inode *inode, 48 - struct qstr *qstr); 41 + static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr); 42 + static int isofs_hash_ms(const struct dentry *parent, struct qstr *qstr); 49 43 static int isofs_dentry_cmpi_ms(const struct dentry *parent, 50 - const struct inode *pinode, 51 - const struct dentry *dentry, const struct inode *inode, 44 + const struct dentry *dentry, 52 45 unsigned int len, const char *str, const struct qstr *name); 53 46 static int isofs_dentry_cmp_ms(const struct dentry *parent, 54 - const struct inode *pinode, 55 - const struct dentry *dentry, const struct inode *inode, 47 + const struct dentry *dentry, 56 48 unsigned int len, const char *str, const struct qstr *name); 57 49 #endif 58 50 ··· 257 265 } 258 266 259 267 static int 260 - isofs_hash(const struct dentry *dentry, const struct inode *inode, 261 - struct qstr *qstr) 268 + isofs_hash(const struct dentry *dentry, struct qstr *qstr) 262 269 { 263 270 return isofs_hash_common(dentry, qstr, 0); 264 271 } 265 272 266 273 static int 267 - isofs_hashi(const struct dentry *dentry, const struct inode *inode, 268 - struct qstr *qstr) 274 + isofs_hashi(const struct dentry *dentry, struct qstr *qstr) 269 275 { 270 276 return isofs_hashi_common(dentry, qstr, 0); 271 277 } 272 278 273 279 static int 274 - isofs_dentry_cmp(const struct dentry *parent, const struct inode *pinode, 275 - const struct dentry *dentry, const struct inode *inode, 280 + isofs_dentry_cmp(const struct dentry *parent, const struct dentry *dentry, 276 281 unsigned int len, const char *str, const struct qstr *name) 277 282 { 278 283 return isofs_dentry_cmp_common(len, str, name, 0, 0); 279 284 } 280 285 281 286 static int 282 - isofs_dentry_cmpi(const struct dentry *parent, const struct inode *pinode, 283 - const struct dentry *dentry, const struct inode *inode, 287 + isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry, 284 288 unsigned int len, const char *str, const struct qstr *name) 285 289 { 286 290 return isofs_dentry_cmp_common(len, str, name, 0, 1); ··· 284 296 285 297 #ifdef CONFIG_JOLIET 286 298 static int 287 - isofs_hash_ms(const struct dentry *dentry, const struct inode *inode, 288 - struct qstr *qstr) 299 + isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr) 289 300 { 290 301 return isofs_hash_common(dentry, qstr, 1); 291 302 } 292 303 293 304 static int 294 - isofs_hashi_ms(const struct dentry *dentry, const struct inode *inode, 295 - struct qstr *qstr) 305 + isofs_hashi_ms(const struct dentry *dentry, struct qstr *qstr) 296 306 { 297 307 return isofs_hashi_common(dentry, qstr, 1); 298 308 } 299 309 300 310 static int 301 - isofs_dentry_cmp_ms(const struct dentry *parent, const struct inode *pinode, 302 - const struct dentry *dentry, const struct inode *inode, 311 + isofs_dentry_cmp_ms(const struct dentry *parent, const struct dentry *dentry, 303 312 unsigned int len, const char *str, const struct qstr *name) 304 313 { 305 314 return isofs_dentry_cmp_common(len, str, name, 1, 0); 306 315 } 307 316 308 317 static int 309 - isofs_dentry_cmpi_ms(const struct dentry *parent, const struct inode *pinode, 310 - const struct dentry *dentry, const struct inode *inode, 318 + isofs_dentry_cmpi_ms(const struct dentry *parent, const struct dentry *dentry, 311 319 unsigned int len, const char *str, const struct qstr *name) 312 320 { 313 321 return isofs_dentry_cmp_common(len, str, name, 1, 1);
+1 -2
fs/isofs/namei.c
··· 37 37 38 38 qstr.name = compare; 39 39 qstr.len = dlen; 40 - return dentry->d_op->d_compare(NULL, NULL, NULL, NULL, 41 - dentry->d_name.len, dentry->d_name.name, &qstr); 40 + return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr); 42 41 } 43 42 44 43 /*
+2 -5
fs/jfs/namei.c
··· 1538 1538 .llseek = generic_file_llseek, 1539 1539 }; 1540 1540 1541 - static int jfs_ci_hash(const struct dentry *dir, const struct inode *inode, 1542 - struct qstr *this) 1541 + static int jfs_ci_hash(const struct dentry *dir, struct qstr *this) 1543 1542 { 1544 1543 unsigned long hash; 1545 1544 int i; ··· 1551 1552 return 0; 1552 1553 } 1553 1554 1554 - static int jfs_ci_compare(const struct dentry *parent, 1555 - const struct inode *pinode, 1556 - const struct dentry *dentry, const struct inode *inode, 1555 + static int jfs_ci_compare(const struct dentry *parent, const struct dentry *dentry, 1557 1556 unsigned int len, const char *str, const struct qstr *name) 1558 1557 { 1559 1558 int i, result = 1;
+3 -4
fs/namei.c
··· 1352 1352 */ 1353 1353 if (nd->flags & LOOKUP_RCU) { 1354 1354 unsigned seq; 1355 - dentry = __d_lookup_rcu(parent, &nd->last, &seq, nd->inode); 1355 + dentry = __d_lookup_rcu(parent, &nd->last, &seq); 1356 1356 if (!dentry) 1357 1357 goto unlazy; 1358 1358 ··· 1787 1787 struct dentry *parent = nd->path.dentry; 1788 1788 nd->flags &= ~LOOKUP_JUMPED; 1789 1789 if (unlikely(parent->d_flags & DCACHE_OP_HASH)) { 1790 - err = parent->d_op->d_hash(parent, nd->inode, 1791 - &this); 1790 + err = parent->d_op->d_hash(parent, &this); 1792 1791 if (err < 0) 1793 1792 break; 1794 1793 } ··· 2120 2121 * to use its own hash.. 2121 2122 */ 2122 2123 if (base->d_flags & DCACHE_OP_HASH) { 2123 - int err = base->d_op->d_hash(base, base->d_inode, &this); 2124 + int err = base->d_op->d_hash(base, &this); 2124 2125 if (err < 0) 2125 2126 return ERR_PTR(err); 2126 2127 }
+24 -8
fs/ncpfs/dir.c
··· 73 73 * Dentry operations routines 74 74 */ 75 75 static int ncp_lookup_validate(struct dentry *, unsigned int); 76 - static int ncp_hash_dentry(const struct dentry *, const struct inode *, 77 - struct qstr *); 78 - static int ncp_compare_dentry(const struct dentry *, const struct inode *, 79 - const struct dentry *, const struct inode *, 76 + static int ncp_hash_dentry(const struct dentry *, struct qstr *); 77 + static int ncp_compare_dentry(const struct dentry *, const struct dentry *, 80 78 unsigned int, const char *, const struct qstr *); 81 79 static int ncp_delete_dentry(const struct dentry *); 82 80 ··· 117 119 /* 118 120 * Note: leave the hash unchanged if the directory 119 121 * is case-sensitive. 122 + * 123 + * Accessing the parent inode can be racy under RCU pathwalking. 124 + * Use ACCESS_ONCE() to make sure we use _one_ particular inode, 125 + * the callers will handle races. 120 126 */ 121 127 static int 122 - ncp_hash_dentry(const struct dentry *dentry, const struct inode *inode, 123 - struct qstr *this) 128 + ncp_hash_dentry(const struct dentry *dentry, struct qstr *this) 124 129 { 130 + struct inode *inode = ACCESS_ONCE(dentry->d_inode); 131 + 132 + if (!inode) 133 + return 0; 134 + 125 135 if (!ncp_case_sensitive(inode)) { 126 136 struct super_block *sb = dentry->d_sb; 127 137 struct nls_table *t; ··· 146 140 return 0; 147 141 } 148 142 143 + /* 144 + * Accessing the parent inode can be racy under RCU pathwalking. 145 + * Use ACCESS_ONCE() to make sure we use _one_ particular inode, 146 + * the callers will handle races. 147 + */ 149 148 static int 150 - ncp_compare_dentry(const struct dentry *parent, const struct inode *pinode, 151 - const struct dentry *dentry, const struct inode *inode, 149 + ncp_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 152 150 unsigned int len, const char *str, const struct qstr *name) 153 151 { 152 + struct inode *pinode; 153 + 154 154 if (len != name->len) 155 + return 1; 156 + 157 + pinode = ACCESS_ONCE(parent->d_inode); 158 + if (!pinode) 155 159 return 1; 156 160 157 161 if (ncp_case_sensitive(pinode))
+4 -3
fs/proc/proc_sysctl.c
··· 796 796 return res; 797 797 } 798 798 799 - static int proc_sys_compare(const struct dentry *parent, 800 - const struct inode *pinode, 801 - const struct dentry *dentry, const struct inode *inode, 799 + static int proc_sys_compare(const struct dentry *parent, const struct dentry *dentry, 802 800 unsigned int len, const char *str, const struct qstr *name) 803 801 { 804 802 struct ctl_table_header *head; 803 + struct inode *inode; 804 + 805 805 /* Although proc doesn't have negative dentries, rcu-walk means 806 806 * that inode here can be NULL */ 807 807 /* AV: can it, indeed? */ 808 + inode = ACCESS_ONCE(dentry->d_inode); 808 809 if (!inode) 809 810 return 1; 810 811 if (name->len != len)
+1 -2
fs/sysv/namei.c
··· 27 27 return err; 28 28 } 29 29 30 - static int sysv_hash(const struct dentry *dentry, const struct inode *inode, 31 - struct qstr *qstr) 30 + static int sysv_hash(const struct dentry *dentry, struct qstr *qstr) 32 31 { 33 32 /* Truncate the name in place, avoids having to define a compare 34 33 function. */
+3 -6
include/linux/dcache.h
··· 146 146 struct dentry_operations { 147 147 int (*d_revalidate)(struct dentry *, unsigned int); 148 148 int (*d_weak_revalidate)(struct dentry *, unsigned int); 149 - int (*d_hash)(const struct dentry *, const struct inode *, 150 - struct qstr *); 151 - int (*d_compare)(const struct dentry *, const struct inode *, 152 - const struct dentry *, const struct inode *, 149 + int (*d_hash)(const struct dentry *, struct qstr *); 150 + int (*d_compare)(const struct dentry *, const struct dentry *, 153 151 unsigned int, const char *, const struct qstr *); 154 152 int (*d_delete)(const struct dentry *); 155 153 void (*d_release)(struct dentry *); ··· 300 302 extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *); 301 303 extern struct dentry *__d_lookup(const struct dentry *, const struct qstr *); 302 304 extern struct dentry *__d_lookup_rcu(const struct dentry *parent, 303 - const struct qstr *name, 304 - unsigned *seq, struct inode *inode); 305 + const struct qstr *name, unsigned *seq); 305 306 306 307 /** 307 308 * __d_rcu_to_refcount - take a refcount on dentry if sequence check is ok