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.

Merge branch 'work.lookup' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs lookup() updates from Al Viro:
"More conversions of ->lookup() to d_splice_alias().

Should be reasonably complete now - the only leftovers are in ceph"

* 'work.lookup' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
afs_try_auto_mntpt(): return NULL instead of ERR_PTR(-ENOENT)
afs_lookup(): switch to d_splice_alias()
afs: switch dynroot lookups to d_splice_alias()
hpfs: fix an inode leak in lookup, switch to d_splice_alias()
hostfs_lookup: switch to d_splice_alias()

+28 -95
+10 -35
fs/afs/dir.c
··· 822 822 { 823 823 struct afs_vnode *dvnode = AFS_FS_I(dir); 824 824 struct inode *inode; 825 + struct dentry *d; 825 826 struct key *key; 826 827 int ret; 827 828 ··· 863 862 864 863 afs_stat_v(dvnode, n_lookup); 865 864 inode = afs_do_lookup(dir, dentry, key); 866 - if (IS_ERR(inode)) { 867 - ret = PTR_ERR(inode); 868 - if (ret == -ENOENT) { 869 - inode = afs_try_auto_mntpt(dentry, dir); 870 - if (!IS_ERR(inode)) { 871 - key_put(key); 872 - goto success; 873 - } 874 - 875 - ret = PTR_ERR(inode); 876 - } 877 - 878 - key_put(key); 879 - if (ret == -ENOENT) { 880 - d_add(dentry, NULL); 881 - _leave(" = NULL [negative]"); 882 - return NULL; 883 - } 884 - _leave(" = %d [do]", ret); 885 - return ERR_PTR(ret); 886 - } 887 - dentry->d_fsdata = (void *)(unsigned long)dvnode->status.data_version; 888 - 889 - /* instantiate the dentry */ 890 865 key_put(key); 891 - if (IS_ERR(inode)) { 892 - _leave(" = %ld", PTR_ERR(inode)); 893 - return ERR_CAST(inode); 866 + if (inode == ERR_PTR(-ENOENT)) { 867 + inode = afs_try_auto_mntpt(dentry, dir); 868 + } else { 869 + dentry->d_fsdata = 870 + (void *)(unsigned long)dvnode->status.data_version; 894 871 } 895 - 896 - success: 897 - d_add(dentry, inode); 898 - _leave(" = 0 { ino=%lu v=%u }", 899 - d_inode(dentry)->i_ino, 900 - d_inode(dentry)->i_generation); 901 - 902 - return NULL; 872 + d = d_splice_alias(inode, dentry); 873 + if (!IS_ERR_OR_NULL(d)) 874 + d->d_fsdata = dentry->d_fsdata; 875 + return d; 903 876 } 904 877 905 878 /*
+2 -23
fs/afs/dynroot.c
··· 83 83 84 84 out: 85 85 _leave("= %d", ret); 86 - return ERR_PTR(ret); 86 + return ret == -ENOENT ? NULL : ERR_PTR(ret); 87 87 } 88 88 89 89 /* ··· 141 141 static struct dentry *afs_dynroot_lookup(struct inode *dir, struct dentry *dentry, 142 142 unsigned int flags) 143 143 { 144 - struct afs_vnode *vnode; 145 - struct inode *inode; 146 - int ret; 147 - 148 - vnode = AFS_FS_I(dir); 149 - 150 144 _enter("%pd", dentry); 151 145 152 146 ASSERTCMP(d_inode(dentry), ==, NULL); ··· 154 160 memcmp(dentry->d_name.name, "@cell", 5) == 0) 155 161 return afs_lookup_atcell(dentry); 156 162 157 - inode = afs_try_auto_mntpt(dentry, dir); 158 - if (IS_ERR(inode)) { 159 - ret = PTR_ERR(inode); 160 - if (ret == -ENOENT) { 161 - d_add(dentry, NULL); 162 - _leave(" = NULL [negative]"); 163 - return NULL; 164 - } 165 - _leave(" = %d [do]", ret); 166 - return ERR_PTR(ret); 167 - } 168 - 169 - d_add(dentry, inode); 170 - _leave(" = 0 { ino=%lu v=%u }", 171 - d_inode(dentry)->i_ino, d_inode(dentry)->i_generation); 172 - return NULL; 163 + return d_splice_alias(afs_try_auto_mntpt(dentry, dir), dentry); 173 164 } 174 165 175 166 const struct inode_operations afs_dynroot_inode_operations = {
+9 -21
fs/hostfs/hostfs_kern.c
··· 610 610 int err; 611 611 612 612 inode = hostfs_iget(ino->i_sb); 613 - if (IS_ERR(inode)) { 614 - err = PTR_ERR(inode); 613 + if (IS_ERR(inode)) 615 614 goto out; 616 - } 617 615 618 616 err = -ENOMEM; 619 617 name = dentry_name(dentry); 620 - if (name == NULL) 621 - goto out_put; 622 - 623 - err = read_name(inode, name); 624 - 625 - __putname(name); 626 - if (err == -ENOENT) { 627 - iput(inode); 628 - inode = NULL; 618 + if (name) { 619 + err = read_name(inode, name); 620 + __putname(name); 629 621 } 630 - else if (err) 631 - goto out_put; 632 - 633 - d_add(dentry, inode); 634 - return NULL; 635 - 636 - out_put: 637 - iput(inode); 622 + if (err) { 623 + iput(inode); 624 + inode = (err == -ENOENT) ? NULL : ERR_PTR(err); 625 + } 638 626 out: 639 - return ERR_PTR(err); 627 + return d_splice_alias(inode, dentry); 640 628 } 641 629 642 630 static int hostfs_link(struct dentry *to, struct inode *ino,
+7 -16
fs/hpfs/dir.c
··· 244 244 result = iget_locked(dir->i_sb, ino); 245 245 if (!result) { 246 246 hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode"); 247 + result = ERR_PTR(-ENOMEM); 247 248 goto bail1; 248 249 } 249 250 if (result->i_state & I_NEW) { ··· 267 266 268 267 if (de->has_acl || de->has_xtd_perm) if (!sb_rdonly(dir->i_sb)) { 269 268 hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures"); 269 + iput(result); 270 + result = ERR_PTR(-EINVAL); 270 271 goto bail1; 271 272 } 272 273 ··· 304 301 } 305 302 } 306 303 304 + bail1: 307 305 hpfs_brelse4(&qbh); 308 306 309 307 /* 310 308 * Made it. 311 309 */ 312 310 313 - end: 314 - end_add: 311 + end: 312 + end_add: 315 313 hpfs_unlock(dir->i_sb); 316 - d_add(dentry, result); 317 - return NULL; 318 - 319 - /* 320 - * Didn't. 321 - */ 322 - bail1: 323 - 324 - hpfs_brelse4(&qbh); 325 - 326 - /*bail:*/ 327 - 328 - hpfs_unlock(dir->i_sb); 329 - return ERR_PTR(-ENOENT); 314 + return d_splice_alias(result, dentry); 330 315 } 331 316 332 317 const struct file_operations hpfs_dir_ops =