* [PATCH 2/2] NFS: check xdr_decode for errors
@ 2010-10-22 14:16 Bryan Schumaker
0 siblings, 0 replies; only message in thread
From: Bryan Schumaker @ 2010-10-22 14:16 UTC (permalink / raw)
To: linux-nfs@vger.kernel.org; +Cc: Myklebust, Trond
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>
---
fs/nfs/dir.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 628eca7..da3c103 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
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;
@@ -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);
}
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-10-22 14:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-22 14:16 [PATCH 2/2] NFS: check xdr_decode for errors Bryan Schumaker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).