diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-12-14 09:58:11 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-12-16 12:37:24 -0500 |
commit | 573c4e1ef53a6b891b73cc2257e1604da754a2e4 (patch) | |
tree | b1e01ca46472ac6c936c4a144c3a160d8e1595bb /fs/nfs/nfs4xdr.c | |
parent | 8111f373600cd43b3198b48b9238e3ad2fd9908d (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/nfs4xdr.c')
-rw-r--r-- | fs/nfs/nfs4xdr.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 868815c55450..be9f00ab0d18 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -6159,8 +6159,22 @@ out: | |||
6159 | } | 6159 | } |
6160 | #endif /* CONFIG_NFS_V4_1 */ | 6160 | #endif /* CONFIG_NFS_V4_1 */ |
6161 | 6161 | ||
6162 | __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | 6162 | /** |
6163 | struct nfs_server *server, int plus) | 6163 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
6164 | * the local page cache. | ||
6165 | * @xdr: XDR stream where entry resides | ||
6166 | * @entry: buffer to fill in with entry data | ||
6167 | * @plus: boolean indicating whether this should be a readdirplus entry | ||
6168 | * | ||
6169 | * Returns zero if successful, otherwise a negative errno value is | ||
6170 | * returned. | ||
6171 | * | ||
6172 | * This function is not invoked during READDIR reply decoding, but | ||
6173 | * rather whenever an application invokes the getdents(2) system call | ||
6174 | * on a directory already in our cache. | ||
6175 | */ | ||
6176 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | ||
6177 | int plus) | ||
6164 | { | 6178 | { |
6165 | uint32_t bitmap[2] = {0}; | 6179 | uint32_t bitmap[2] = {0}; |
6166 | uint32_t len; | 6180 | uint32_t len; |
@@ -6172,9 +6186,9 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | |||
6172 | if (unlikely(!p)) | 6186 | if (unlikely(!p)) |
6173 | goto out_overflow; | 6187 | goto out_overflow; |
6174 | if (!ntohl(*p++)) | 6188 | if (!ntohl(*p++)) |
6175 | return ERR_PTR(-EAGAIN); | 6189 | return -EAGAIN; |
6176 | entry->eof = 1; | 6190 | entry->eof = 1; |
6177 | return ERR_PTR(-EBADCOOKIE); | 6191 | return -EBADCOOKIE; |
6178 | } | 6192 | } |
6179 | 6193 | ||
6180 | p = xdr_inline_decode(xdr, 12); | 6194 | p = xdr_inline_decode(xdr, 12); |
@@ -6203,7 +6217,8 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | |||
6203 | if (decode_attr_length(xdr, &len, &p) < 0) | 6217 | if (decode_attr_length(xdr, &len, &p) < 0) |
6204 | goto out_overflow; | 6218 | goto out_overflow; |
6205 | 6219 | ||
6206 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, server, 1) < 0) | 6220 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
6221 | entry->server, 1) < 0) | ||
6207 | goto out_overflow; | 6222 | goto out_overflow; |
6208 | if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) | 6223 | if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
6209 | entry->ino = entry->fattr->fileid; | 6224 | entry->ino = entry->fattr->fileid; |
@@ -6221,11 +6236,11 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | |||
6221 | else | 6236 | else |
6222 | entry->eof = 0; | 6237 | entry->eof = 0; |
6223 | 6238 | ||
6224 | return p; | 6239 | return 0; |
6225 | 6240 | ||
6226 | out_overflow: | 6241 | out_overflow: |
6227 | print_overflow_msg(__func__, xdr); | 6242 | print_overflow_msg(__func__, xdr); |
6228 | return ERR_PTR(-EAGAIN); | 6243 | return -EAGAIN; |
6229 | } | 6244 | } |
6230 | 6245 | ||
6231 | /* | 6246 | /* |