diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-14 19:24:48 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-22 14:28:02 -0400 |
commit | 500e2ab6c39b62c4b16e9964ed8990f091a47ddb (patch) | |
tree | 3cabc280c27682a470aa2dad824755e919f5ed0e | |
parent | 1c5fedbb508fe8b206ada3115811870f44128471 (diff) |
9p: unify paths in v9fs_vfs_lookup()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/9p/vfs_inode.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 9ee534159cc6..42e102e2e74a 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -823,28 +823,21 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
823 | if (IS_ERR(dfid)) | 823 | if (IS_ERR(dfid)) |
824 | return ERR_CAST(dfid); | 824 | return ERR_CAST(dfid); |
825 | 825 | ||
826 | name = dentry->d_name.name; | ||
827 | fid = p9_client_walk(dfid, 1, &name, 1); | ||
828 | if (IS_ERR(fid)) { | ||
829 | if (fid == ERR_PTR(-ENOENT)) { | ||
830 | d_add(dentry, NULL); | ||
831 | return NULL; | ||
832 | } | ||
833 | return ERR_CAST(fid); | ||
834 | } | ||
835 | /* | 826 | /* |
836 | * Make sure we don't use a wrong inode due to parallel | 827 | * Make sure we don't use a wrong inode due to parallel |
837 | * unlink. For cached mode create calls request for new | 828 | * unlink. For cached mode create calls request for new |
838 | * inode. But with cache disabled, lookup should do this. | 829 | * inode. But with cache disabled, lookup should do this. |
839 | */ | 830 | */ |
840 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) | 831 | name = dentry->d_name.name; |
832 | fid = p9_client_walk(dfid, 1, &name, 1); | ||
833 | if (fid == ERR_PTR(-ENOENT)) | ||
834 | inode = NULL; | ||
835 | else if (IS_ERR(fid)) | ||
836 | inode = ERR_CAST(fid); | ||
837 | else if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) | ||
841 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); | 838 | inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); |
842 | else | 839 | else |
843 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); | 840 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); |
844 | if (IS_ERR(inode)) { | ||
845 | p9_client_clunk(fid); | ||
846 | return ERR_CAST(inode); | ||
847 | } | ||
848 | /* | 841 | /* |
849 | * If we had a rename on the server and a parallel lookup | 842 | * If we had a rename on the server and a parallel lookup |
850 | * for the new name, then make sure we instantiate with | 843 | * for the new name, then make sure we instantiate with |
@@ -853,12 +846,14 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
853 | * k/b. | 846 | * k/b. |
854 | */ | 847 | */ |
855 | res = d_splice_alias(inode, dentry); | 848 | res = d_splice_alias(inode, dentry); |
856 | if (!res) | 849 | if (!IS_ERR(fid)) { |
857 | v9fs_fid_add(dentry, fid); | 850 | if (!res) |
858 | else if (!IS_ERR(res)) | 851 | v9fs_fid_add(dentry, fid); |
859 | v9fs_fid_add(res, fid); | 852 | else if (!IS_ERR(res)) |
860 | else | 853 | v9fs_fid_add(res, fid); |
861 | p9_client_clunk(fid); | 854 | else |
855 | p9_client_clunk(fid); | ||
856 | } | ||
862 | return res; | 857 | return res; |
863 | } | 858 | } |
864 | 859 | ||