Commit eb229d25 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] kNFSd: fix two xdr-encode bugs for readdirplus reply

More fall-out from the change to allow multi-page replies to readdir
requests.
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 57b6949e
...@@ -492,8 +492,16 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp, ...@@ -492,8 +492,16 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
count += PAGE_SIZE; count += PAGE_SIZE;
} }
resp->count = count >> 2; resp->count = count >> 2;
if (resp->offset) if (resp->offset) {
if (unlikely(resp->offset1)) {
/* we ended up with offset on a page boundary */
*resp->offset = htonl(offset >> 32);
*resp->offset1 = htonl(offset & 0xffffffff);
resp->offset1 = NULL;
} else {
xdr_encode_hyper(resp->offset, offset); xdr_encode_hyper(resp->offset, offset);
}
}
RETURN_STATUS(nfserr); RETURN_STATUS(nfserr);
} }
......
...@@ -762,10 +762,16 @@ nfs3svc_encode_readdirres(struct svc_rqst *rqstp, u32 *p, ...@@ -762,10 +762,16 @@ nfs3svc_encode_readdirres(struct svc_rqst *rqstp, u32 *p,
/* stupid readdir cookie */ /* stupid readdir cookie */
memcpy(p, resp->verf, 8); p += 2; memcpy(p, resp->verf, 8); p += 2;
xdr_ressize_check(rqstp, p); xdr_ressize_check(rqstp, p);
p = resp->buffer; if (rqstp->rq_res.head[0].iov_len + (2<<2) > PAGE_SIZE)
return 1; /*No room for trailer */
rqstp->rq_res.page_len = (resp->count) << 2;
/* add the 'tail' to the end of the 'head' page - page 0. */
rqstp->rq_restailpage = 0;
rqstp->rq_res.tail[0].iov_base = p;
*p++ = 0; /* no more entries */ *p++ = 0; /* no more entries */
*p++ = htonl(resp->common.err == nfserr_eof); *p++ = htonl(resp->common.err == nfserr_eof);
rqstp->rq_res.page_len = (resp->count + 2) << 2; rqstp->rq_res.tail[0].iov_len = 2<<2;
return 1; return 1;
} else } else
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment