aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:48 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:48 -0500
commit03f28e3a2059fc466761d872122f30acb7be61ae (patch)
treed478e553b79520c34bb3d06e75b59609de2993f4 /fs/nfs
parent01d0ae8beaee75d954900109619b700fe68707d9 (diff)
NFS: Make nfs_fhget() return appropriate error values
Currently it returns NULL, which usually gets interpreted as ENOMEM. In fact it can mean a host of issues. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/dir.c10
-rw-r--r--fs/nfs/inode.c15
-rw-r--r--fs/nfs/nfs4proc.c2
3 files changed, 13 insertions, 14 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 609185a15c99..06c48b385c94 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -901,9 +901,9 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
901 res = ERR_PTR(error); 901 res = ERR_PTR(error);
902 goto out_unlock; 902 goto out_unlock;
903 } 903 }
904 res = ERR_PTR(-EACCES);
905 inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); 904 inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr);
906 if (!inode) 905 res = (struct dentry *)inode;
906 if (IS_ERR(res))
907 goto out_unlock; 907 goto out_unlock;
908no_entry: 908no_entry:
909 res = d_add_unique(dentry, inode); 909 res = d_add_unique(dentry, inode);
@@ -1096,7 +1096,7 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
1096 return NULL; 1096 return NULL;
1097 dentry->d_op = NFS_PROTO(dir)->dentry_ops; 1097 dentry->d_op = NFS_PROTO(dir)->dentry_ops;
1098 inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr); 1098 inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr);
1099 if (!inode) { 1099 if (IS_ERR(inode)) {
1100 dput(dentry); 1100 dput(dentry);
1101 return NULL; 1101 return NULL;
1102 } 1102 }
@@ -1134,9 +1134,9 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1134 if (error < 0) 1134 if (error < 0)
1135 goto out_err; 1135 goto out_err;
1136 } 1136 }
1137 error = -ENOMEM;
1138 inode = nfs_fhget(dentry->d_sb, fhandle, fattr); 1137 inode = nfs_fhget(dentry->d_sb, fhandle, fattr);
1139 if (inode == NULL) 1138 error = PTR_ERR(inode);
1139 if (IS_ERR(inode))
1140 goto out_err; 1140 goto out_err;
1141 d_instantiate(dentry, inode); 1141 d_instantiate(dentry, inode);
1142 return 0; 1142 return 0;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 17654bffc3c6..a0cda53461b3 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -241,7 +241,6 @@ static struct inode *
241nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *fsinfo) 241nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *fsinfo)
242{ 242{
243 struct nfs_server *server = NFS_SB(sb); 243 struct nfs_server *server = NFS_SB(sb);
244 struct inode *rooti;
245 int error; 244 int error;
246 245
247 error = server->rpc_ops->getroot(server, rootfh, fsinfo); 246 error = server->rpc_ops->getroot(server, rootfh, fsinfo);
@@ -250,10 +249,7 @@ nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *f
250 return ERR_PTR(error); 249 return ERR_PTR(error);
251 } 250 }
252 251
253 rooti = nfs_fhget(sb, rootfh, fsinfo->fattr); 252 return nfs_fhget(sb, rootfh, fsinfo->fattr);
254 if (!rooti)
255 return ERR_PTR(-ENOMEM);
256 return rooti;
257} 253}
258 254
259/* 255/*
@@ -853,7 +849,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
853 .fh = fh, 849 .fh = fh,
854 .fattr = fattr 850 .fattr = fattr
855 }; 851 };
856 struct inode *inode = NULL; 852 struct inode *inode = ERR_PTR(-ENOENT);
857 unsigned long hash; 853 unsigned long hash;
858 854
859 if ((fattr->valid & NFS_ATTR_FATTR) == 0) 855 if ((fattr->valid & NFS_ATTR_FATTR) == 0)
@@ -866,8 +862,11 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
866 862
867 hash = nfs_fattr_to_ino_t(fattr); 863 hash = nfs_fattr_to_ino_t(fattr);
868 864
869 if (!(inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc))) 865 inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc);
866 if (inode == NULL) {
867 inode = ERR_PTR(-ENOMEM);
870 goto out_no_inode; 868 goto out_no_inode;
869 }
871 870
872 if (inode->i_state & I_NEW) { 871 if (inode->i_state & I_NEW) {
873 struct nfs_inode *nfsi = NFS_I(inode); 872 struct nfs_inode *nfsi = NFS_I(inode);
@@ -936,7 +935,7 @@ out:
936 return inode; 935 return inode;
937 936
938out_no_inode: 937out_no_inode:
939 printk("nfs_fhget: iget failed\n"); 938 dprintk("nfs_fhget: iget failed with error %ld\n", PTR_ERR(inode));
940 goto out; 939 goto out;
941} 940}
942 941
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 31000326aba4..02c7d8c04c58 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -336,7 +336,7 @@ static struct nfs4_state *nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data
336 if (!(data->f_attr.valid & NFS_ATTR_FATTR)) 336 if (!(data->f_attr.valid & NFS_ATTR_FATTR))
337 goto out; 337 goto out;
338 inode = nfs_fhget(data->dir->d_sb, &data->o_res.fh, &data->f_attr); 338 inode = nfs_fhget(data->dir->d_sb, &data->o_res.fh, &data->f_attr);
339 if (inode == NULL) 339 if (IS_ERR(inode))
340 goto out; 340 goto out;
341 state = nfs4_get_open_state(inode, data->owner); 341 state = nfs4_get_open_state(inode, data->owner);
342 if (state == NULL) 342 if (state == NULL)