diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-06-24 10:43:51 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-08-05 15:44:14 -0400 |
commit | 34b2a88fb4aa4de34e1d5f9fc2761b746980f9b1 (patch) | |
tree | 0e8d0acb50520154d040fa7401e0c70282c58a31 /fs/afs | |
parent | 855371bd01b4cd8cf0e2b8ca172a5c30a481f963 (diff) |
afs_lookup(): switch to d_splice_alias()
->lookup() methods can (and should) use d_splice_alias() instead of
d_add(). Even if they are not going to be hit by open_by_handle(),
code does get copied around; besides, d_splice_alias() has better
calling conventions for use in ->lookup(), so the code gets simpler.
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/afs')
-rw-r--r-- | fs/afs/dir.c | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 7d623008157f..52f44255f65d 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c | |||
@@ -822,6 +822,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, | |||
822 | { | 822 | { |
823 | struct afs_vnode *dvnode = AFS_FS_I(dir); | 823 | struct afs_vnode *dvnode = AFS_FS_I(dir); |
824 | struct inode *inode; | 824 | struct inode *inode; |
825 | struct dentry *d; | ||
825 | struct key *key; | 826 | struct key *key; |
826 | int ret; | 827 | int ret; |
827 | 828 | ||
@@ -862,43 +863,19 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, | |||
862 | 863 | ||
863 | afs_stat_v(dvnode, n_lookup); | 864 | afs_stat_v(dvnode, n_lookup); |
864 | inode = afs_do_lookup(dir, dentry, key); | 865 | inode = afs_do_lookup(dir, dentry, key); |
865 | if (IS_ERR(inode)) { | ||
866 | ret = PTR_ERR(inode); | ||
867 | if (ret == -ENOENT) { | ||
868 | inode = afs_try_auto_mntpt(dentry, dir); | ||
869 | if (!IS_ERR(inode)) { | ||
870 | key_put(key); | ||
871 | goto success; | ||
872 | } | ||
873 | |||
874 | ret = PTR_ERR(inode); | ||
875 | } | ||
876 | |||
877 | key_put(key); | ||
878 | if (ret == -ENOENT) { | ||
879 | d_add(dentry, NULL); | ||
880 | _leave(" = NULL [negative]"); | ||
881 | return NULL; | ||
882 | } | ||
883 | _leave(" = %d [do]", ret); | ||
884 | return ERR_PTR(ret); | ||
885 | } | ||
886 | dentry->d_fsdata = (void *)(unsigned long)dvnode->status.data_version; | ||
887 | |||
888 | /* instantiate the dentry */ | ||
889 | key_put(key); | 866 | key_put(key); |
890 | if (IS_ERR(inode)) { | 867 | if (inode == ERR_PTR(-ENOENT)) { |
891 | _leave(" = %ld", PTR_ERR(inode)); | 868 | inode = afs_try_auto_mntpt(dentry, dir); |
892 | return ERR_CAST(inode); | 869 | if (inode == ERR_PTR(-ENOENT)) |
870 | inode = NULL; | ||
871 | } else { | ||
872 | dentry->d_fsdata = | ||
873 | (void *)(unsigned long)dvnode->status.data_version; | ||
893 | } | 874 | } |
894 | 875 | d = d_splice_alias(inode, dentry); | |
895 | success: | 876 | if (!IS_ERR_OR_NULL(d)) |
896 | d_add(dentry, inode); | 877 | d->d_fsdata = dentry->d_fsdata; |
897 | _leave(" = 0 { ino=%lu v=%u }", | 878 | return d; |
898 | d_inode(dentry)->i_ino, | ||
899 | d_inode(dentry)->i_generation); | ||
900 | |||
901 | return NULL; | ||
902 | } | 879 | } |
903 | 880 | ||
904 | /* | 881 | /* |