aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/dir.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2010-10-21 16:33:16 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-10-23 15:27:36 -0400
commit9942438089d5c0e3adecdcb7bc360b8fe0ce7e62 (patch)
tree6c6fa331811f6c8e5217193276602bd353613061 /fs/nfs/dir.c
parent3c8a1aeed8fd7f89bd0400fad72cbc1ac3460217 (diff)
NFS: check xdr_decode for errors
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>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r--fs/nfs/dir.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 7b8b7c59db9f..0cbb714a09d8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -442,6 +442,8 @@ void nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *e
442 struct xdr_stream stream; 442 struct xdr_stream stream;
443 struct xdr_buf buf; 443 struct xdr_buf buf;
444 __be32 *ptr = xdr_page; 444 __be32 *ptr = xdr_page;
445 int status;
446 struct nfs_cache_array *array;
445 447
446 buf.head->iov_base = xdr_page; 448 buf.head->iov_base = xdr_page;
447 buf.head->iov_len = buflen; 449 buf.head->iov_len = buflen;
@@ -453,11 +455,23 @@ void nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *e
453 455
454 xdr_init_decode(&stream, &buf, ptr); 456 xdr_init_decode(&stream, &buf, ptr);
455 457
456 while (xdr_decode(desc, entry, &stream) == 0) { 458
459 do {
460 status = xdr_decode(desc, entry, &stream);
461 if (status != 0)
462 break;
463
457 if (nfs_readdir_add_to_array(entry, page) == -1) 464 if (nfs_readdir_add_to_array(entry, page) == -1)
458 break; 465 break;
459 if (desc->plus == 1) 466 if (desc->plus == 1)
460 nfs_prime_dcache(desc->file->f_path.dentry, entry); 467 nfs_prime_dcache(desc->file->f_path.dentry, entry);
468 } while (!entry->eof);
469
470 if (status == -EBADCOOKIE && entry->eof) {
471 array = nfs_readdir_get_array(page);
472 array->eof_index = array->size - 1;
473 status = 0;
474 nfs_readdir_release_array(page);
461 } 475 }
462} 476}
463 477