Skip to content

Commit

Permalink
NFS: check xdr_decode for errors
Browse files Browse the repository at this point in the history
Check if the decoded entry has the eof bit set when returning from xdr_decode
with an error.  If it does, we should set the eof bits in the array before
returning.  This should keep us from looping when we expect more data but the
server doesn't give us anything new.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Bryan Schumaker authored and Trond Myklebust committed Oct 23, 2010
1 parent 3c8a1ae commit 9942438
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ void nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *e
struct xdr_stream stream;
struct xdr_buf buf;
__be32 *ptr = xdr_page;
int status;
struct nfs_cache_array *array;

buf.head->iov_base = xdr_page;
buf.head->iov_len = buflen;
Expand All @@ -453,11 +455,23 @@ void nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *e

xdr_init_decode(&stream, &buf, ptr);

while (xdr_decode(desc, entry, &stream) == 0) {

do {
status = xdr_decode(desc, entry, &stream);
if (status != 0)
break;

if (nfs_readdir_add_to_array(entry, page) == -1)
break;
if (desc->plus == 1)
nfs_prime_dcache(desc->file->f_path.dentry, entry);
} while (!entry->eof);

if (status == -EBADCOOKIE && entry->eof) {
array = nfs_readdir_get_array(page);
array->eof_index = array->size - 1;
status = 0;
nfs_readdir_release_array(page);
}
}

Expand Down

0 comments on commit 9942438

Please sign in to comment.