diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2010-10-20 15:44:31 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-10-23 15:27:34 -0400 |
commit | afa8ccc978c24d8ab22e3b3b8cbd1054c84c070b (patch) | |
tree | 77a05498dd1decb19f296f0e9f60da0916a40bbd /fs/nfs/nfs3xdr.c | |
parent | babddc72a9468884ce1a23db3c3d54b0afa299f0 (diff) |
NFS: remove page size checking code
Remove the page size checking code for a readdir decode. This is now done
by decode_dirent with xdr_streams.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs3xdr.c')
-rw-r--r-- | fs/nfs/nfs3xdr.c | 78 |
1 files changed, 1 insertions, 77 deletions
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index d562c8d9d56e..dc98eb7976c3 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c | |||
@@ -554,9 +554,8 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res | |||
554 | struct kvec *iov = rcvbuf->head; | 554 | struct kvec *iov = rcvbuf->head; |
555 | struct page **page; | 555 | struct page **page; |
556 | size_t hdrlen; | 556 | size_t hdrlen; |
557 | u32 len, recvd, pglen; | 557 | u32 recvd, pglen; |
558 | int status, nr = 0; | 558 | int status, nr = 0; |
559 | __be32 *entry, *end, *kaddr; | ||
560 | 559 | ||
561 | status = ntohl(*p++); | 560 | status = ntohl(*p++); |
562 | /* Decode post_op_attrs */ | 561 | /* Decode post_op_attrs */ |
@@ -586,83 +585,8 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res | |||
586 | if (pglen > recvd) | 585 | if (pglen > recvd) |
587 | pglen = recvd; | 586 | pglen = recvd; |
588 | page = rcvbuf->pages; | 587 | page = rcvbuf->pages; |
589 | kaddr = p = kmap_atomic(*page, KM_USER0); | ||
590 | end = (__be32 *)((char *)p + pglen); | ||
591 | entry = p; | ||
592 | |||
593 | /* Make sure the packet actually has a value_follows and EOF entry */ | ||
594 | if ((entry + 1) > end) | ||
595 | goto short_pkt; | ||
596 | |||
597 | for (; *p++; nr++) { | ||
598 | if (p + 3 > end) | ||
599 | goto short_pkt; | ||
600 | p += 2; /* inode # */ | ||
601 | len = ntohl(*p++); /* string length */ | ||
602 | p += XDR_QUADLEN(len) + 2; /* name + cookie */ | ||
603 | if (len > NFS3_MAXNAMLEN) { | ||
604 | dprintk("NFS: giant filename in readdir (len 0x%x)!\n", | ||
605 | len); | ||
606 | goto err_unmap; | ||
607 | } | ||
608 | |||
609 | if (res->plus) { | ||
610 | /* post_op_attr */ | ||
611 | if (p + 2 > end) | ||
612 | goto short_pkt; | ||
613 | if (*p++) { | ||
614 | p += 21; | ||
615 | if (p + 1 > end) | ||
616 | goto short_pkt; | ||
617 | } | ||
618 | /* post_op_fh3 */ | ||
619 | if (*p++) { | ||
620 | if (p + 1 > end) | ||
621 | goto short_pkt; | ||
622 | len = ntohl(*p++); | ||
623 | if (len > NFS3_FHSIZE) { | ||
624 | dprintk("NFS: giant filehandle in " | ||
625 | "readdir (len 0x%x)!\n", len); | ||
626 | goto err_unmap; | ||
627 | } | ||
628 | p += XDR_QUADLEN(len); | ||
629 | } | ||
630 | } | ||
631 | |||
632 | if (p + 2 > end) | ||
633 | goto short_pkt; | ||
634 | entry = p; | ||
635 | } | ||
636 | 588 | ||
637 | /* | ||
638 | * Apparently some server sends responses that are a valid size, but | ||
639 | * contain no entries, and have value_follows==0 and EOF==0. For | ||
640 | * those, just set the EOF marker. | ||
641 | */ | ||
642 | if (!nr && entry[1] == 0) { | ||
643 | dprintk("NFS: readdir reply truncated!\n"); | ||
644 | entry[1] = 1; | ||
645 | } | ||
646 | out: | ||
647 | kunmap_atomic(kaddr, KM_USER0); | ||
648 | return nr; | 589 | return nr; |
649 | short_pkt: | ||
650 | /* | ||
651 | * When we get a short packet there are 2 possibilities. We can | ||
652 | * return an error, or fix up the response to look like a valid | ||
653 | * response and return what we have so far. If there are no | ||
654 | * entries and the packet was short, then return -EIO. If there | ||
655 | * are valid entries in the response, return them and pretend that | ||
656 | * the call was successful, but incomplete. The caller can retry the | ||
657 | * readdir starting at the last cookie. | ||
658 | */ | ||
659 | entry[0] = entry[1] = 0; | ||
660 | if (!nr) | ||
661 | nr = -errno_NFSERR_IO; | ||
662 | goto out; | ||
663 | err_unmap: | ||
664 | nr = -errno_NFSERR_IO; | ||
665 | goto out; | ||
666 | } | 590 | } |
667 | 591 | ||
668 | __be32 * | 592 | __be32 * |