aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs3xdr.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:58:11 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:24 -0500
commit573c4e1ef53a6b891b73cc2257e1604da754a2e4 (patch)
treeb1e01ca46472ac6c936c4a144c3a160d8e1595bb /fs/nfs/nfs3xdr.c
parent8111f373600cd43b3198b48b9238e3ad2fd9908d (diff)
NFS: Simplify ->decode_dirent() calling sequence
Clean up. The pointer returned by ->decode_dirent() is no longer used as a pointer. The only call site (xdr_decode() in fs/nfs/dir.c) simply extracts the errno value encoded in the pointer. Replace the returned pointer with a standard integer errno return value. Also, pass the "server" argument as part of the nfs_entry instead of as a separate parameter. It's faster to derive "server" in nfs_readdir_xdr_to_array() since we already have the directory's inode handy. "server" ought to be invariant for a set of entries in the same directory, right? The legacy versions of decode_dirent() don't use "server" anyway, so it's wasted work for them to derive and pass "server" for each entry. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs3xdr.c')
-rw-r--r--fs/nfs/nfs3xdr.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index c97d00fe849a..15c93ccd90c5 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1970,10 +1970,10 @@ out_status:
1970 * the local page cache 1970 * the local page cache
1971 * @xdr: XDR stream where entry resides 1971 * @xdr: XDR stream where entry resides
1972 * @entry: buffer to fill in with entry data 1972 * @entry: buffer to fill in with entry data
1973 * @server: nfs_server data for this directory
1974 * @plus: boolean indicating whether this should be a readdirplus entry 1973 * @plus: boolean indicating whether this should be a readdirplus entry
1975 * 1974 *
1976 * Returns the position of the next item in the buffer, or an ERR_PTR. 1975 * Returns zero if successful, otherwise a negative errno value is
1976 * returned.
1977 * 1977 *
1978 * This function is not invoked during READDIR reply decoding, but 1978 * This function is not invoked during READDIR reply decoding, but
1979 * rather whenever an application invokes the getdents(2) system call 1979 * rather whenever an application invokes the getdents(2) system call
@@ -2000,8 +2000,8 @@ out_status:
2000 * entryplus3 *nextentry; 2000 * entryplus3 *nextentry;
2001 * }; 2001 * };
2002 */ 2002 */
2003__be32 *nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, 2003int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
2004 struct nfs_server *server, int plus) 2004 int plus)
2005{ 2005{
2006 struct nfs_entry old = *entry; 2006 struct nfs_entry old = *entry;
2007 __be32 *p; 2007 __be32 *p;
@@ -2015,23 +2015,23 @@ __be32 *nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
2015 if (unlikely(p == NULL)) 2015 if (unlikely(p == NULL))
2016 goto out_overflow; 2016 goto out_overflow;
2017 if (*p == xdr_zero) 2017 if (*p == xdr_zero)
2018 return ERR_PTR(-EAGAIN); 2018 return -EAGAIN;
2019 entry->eof = 1; 2019 entry->eof = 1;
2020 return ERR_PTR(-EBADCOOKIE); 2020 return -EBADCOOKIE;
2021 } 2021 }
2022 2022
2023 error = decode_fileid3(xdr, &entry->ino); 2023 error = decode_fileid3(xdr, &entry->ino);
2024 if (unlikely(error)) 2024 if (unlikely(error))
2025 return ERR_PTR(error); 2025 return error;
2026 2026
2027 error = decode_inline_filename3(xdr, &entry->name, &entry->len); 2027 error = decode_inline_filename3(xdr, &entry->name, &entry->len);
2028 if (unlikely(error)) 2028 if (unlikely(error))
2029 return ERR_PTR(error); 2029 return error;
2030 2030
2031 entry->prev_cookie = entry->cookie; 2031 entry->prev_cookie = entry->cookie;
2032 error = decode_cookie3(xdr, &entry->cookie); 2032 error = decode_cookie3(xdr, &entry->cookie);
2033 if (unlikely(error)) 2033 if (unlikely(error))
2034 return ERR_PTR(error); 2034 return error;
2035 2035
2036 entry->d_type = DT_UNKNOWN; 2036 entry->d_type = DT_UNKNOWN;
2037 2037
@@ -2039,7 +2039,7 @@ __be32 *nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
2039 entry->fattr->valid = 0; 2039 entry->fattr->valid = 0;
2040 error = decode_post_op_attr(xdr, entry->fattr); 2040 error = decode_post_op_attr(xdr, entry->fattr);
2041 if (unlikely(error)) 2041 if (unlikely(error))
2042 return ERR_PTR(error); 2042 return error;
2043 if (entry->fattr->valid & NFS_ATTR_FATTR_V3) 2043 if (entry->fattr->valid & NFS_ATTR_FATTR_V3)
2044 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); 2044 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
2045 2045
@@ -2052,7 +2052,7 @@ __be32 *nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
2052 if (unlikely(error)) { 2052 if (unlikely(error)) {
2053 if (error == -E2BIG) 2053 if (error == -E2BIG)
2054 goto out_truncated; 2054 goto out_truncated;
2055 return ERR_PTR(error); 2055 return error;
2056 } 2056 }
2057 } else 2057 } else
2058 zero_nfs_fh3(entry->fh); 2058 zero_nfs_fh3(entry->fh);
@@ -2063,15 +2063,15 @@ __be32 *nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
2063 entry->eof = 0; 2063 entry->eof = 0;
2064 if (p != NULL) 2064 if (p != NULL)
2065 entry->eof = (p[0] == xdr_zero) && (p[1] != xdr_zero); 2065 entry->eof = (p[0] == xdr_zero) && (p[1] != xdr_zero);
2066 return p; 2066 return 0;
2067 2067
2068out_overflow: 2068out_overflow:
2069 print_overflow_msg(__func__, xdr); 2069 print_overflow_msg(__func__, xdr);
2070 return ERR_PTR(-EAGAIN); 2070 return -EAGAIN;
2071out_truncated: 2071out_truncated:
2072 dprintk("NFS: directory entry contains invalid file handle\n"); 2072 dprintk("NFS: directory entry contains invalid file handle\n");
2073 *entry = old; 2073 *entry = old;
2074 return ERR_PTR(-EAGAIN); 2074 return -EAGAIN;
2075} 2075}
2076 2076
2077/* 2077/*