Commit d9014b0f authored by Chuck Lever's avatar Chuck Lever

NFSD: Update the NFSv2 READLINK result encoder to use struct xdr_stream

Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent e3b4ef22
...@@ -151,13 +151,14 @@ nfsd_proc_readlink(struct svc_rqst *rqstp) ...@@ -151,13 +151,14 @@ nfsd_proc_readlink(struct svc_rqst *rqstp)
{ {
struct nfsd_fhandle *argp = rqstp->rq_argp; struct nfsd_fhandle *argp = rqstp->rq_argp;
struct nfsd_readlinkres *resp = rqstp->rq_resp; struct nfsd_readlinkres *resp = rqstp->rq_resp;
char *buffer = page_address(*(rqstp->rq_next_page++));
dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh)); dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh));
/* Read the symlink. */ /* Read the symlink. */
resp->len = NFS_MAXPATHLEN; resp->len = NFS_MAXPATHLEN;
resp->status = nfsd_readlink(rqstp, &argp->fh, buffer, &resp->len); resp->page = *(rqstp->rq_next_page++);
resp->status = nfsd_readlink(rqstp, &argp->fh,
page_address(resp->page), &resp->len);
fh_put(&argp->fh); fh_put(&argp->fh);
return rpc_success; return rpc_success;
......
...@@ -527,24 +527,22 @@ nfssvc_encode_diropres(struct svc_rqst *rqstp, __be32 *p) ...@@ -527,24 +527,22 @@ nfssvc_encode_diropres(struct svc_rqst *rqstp, __be32 *p)
int int
nfssvc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p) nfssvc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p)
{ {
struct xdr_stream *xdr = &rqstp->rq_res_stream;
struct nfsd_readlinkres *resp = rqstp->rq_resp; struct nfsd_readlinkres *resp = rqstp->rq_resp;
struct kvec *head = rqstp->rq_res.head; struct kvec *head = rqstp->rq_res.head;
*p++ = resp->status; if (!svcxdr_encode_stat(xdr, resp->status))
if (resp->status != nfs_ok) return 0;
return xdr_ressize_check(rqstp, p); switch (resp->status) {
case nfs_ok:
*p++ = htonl(resp->len); if (xdr_stream_encode_u32(xdr, resp->len) < 0)
xdr_ressize_check(rqstp, p);
rqstp->rq_res.page_len = resp->len;
if (resp->len & 3) {
/* need to pad the tail */
rqstp->rq_res.tail[0].iov_base = p;
*p = 0;
rqstp->rq_res.tail[0].iov_len = 4 - (resp->len&3);
}
if (svc_encode_result_payload(rqstp, head->iov_len, resp->len))
return 0; return 0;
xdr_write_pages(xdr, &resp->page, 0, resp->len);
if (svc_encode_result_payload(rqstp, head->iov_len, resp->len) < 0)
return 0;
break;
}
return 1; return 1;
} }
......
...@@ -94,6 +94,7 @@ struct nfsd_diropres { ...@@ -94,6 +94,7 @@ struct nfsd_diropres {
struct nfsd_readlinkres { struct nfsd_readlinkres {
__be32 status; __be32 status;
int len; int len;
struct page *page;
}; };
struct nfsd_readres { struct nfsd_readres {
......
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