Commit 788cd46e authored by Chuck Lever's avatar Chuck Lever

NFSD: Add helper to set up the pages where the dirlist is encoded

Add a helper similar to nfsd3_init_dirlist_pages().
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 1fcbd1c9
...@@ -553,6 +553,20 @@ nfsd_proc_rmdir(struct svc_rqst *rqstp) ...@@ -553,6 +553,20 @@ nfsd_proc_rmdir(struct svc_rqst *rqstp)
return rpc_success; return rpc_success;
} }
static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
struct nfsd_readdirres *resp,
int count)
{
count = min_t(u32, count, PAGE_SIZE);
/* Convert byte count to number of words (i.e. >> 2),
* and reserve room for the NULL ptr & eof flag (-2 words) */
resp->buflen = (count >> 2) - 2;
resp->buffer = page_address(*rqstp->rq_next_page);
rqstp->rq_next_page++;
}
/* /*
* Read a portion of a directory. * Read a portion of a directory.
*/ */
...@@ -561,31 +575,24 @@ nfsd_proc_readdir(struct svc_rqst *rqstp) ...@@ -561,31 +575,24 @@ nfsd_proc_readdir(struct svc_rqst *rqstp)
{ {
struct nfsd_readdirargs *argp = rqstp->rq_argp; struct nfsd_readdirargs *argp = rqstp->rq_argp;
struct nfsd_readdirres *resp = rqstp->rq_resp; struct nfsd_readdirres *resp = rqstp->rq_resp;
int count;
loff_t offset; loff_t offset;
__be32 *buffer;
dprintk("nfsd: READDIR %s %d bytes at %d\n", dprintk("nfsd: READDIR %s %d bytes at %d\n",
SVCFH_fmt(&argp->fh), SVCFH_fmt(&argp->fh),
argp->count, argp->cookie); argp->count, argp->cookie);
/* Shrink to the client read size */ nfsd_init_dirlist_pages(rqstp, resp, argp->count);
count = (argp->count >> 2) - 2; buffer = resp->buffer;
/* Make sure we've room for the NULL ptr & eof flag */
count -= 2;
if (count < 0)
count = 0;
resp->buffer = argp->buffer;
resp->offset = NULL; resp->offset = NULL;
resp->buflen = count;
resp->common.err = nfs_ok; resp->common.err = nfs_ok;
/* Read directory and encode entries on the fly */ /* Read directory and encode entries on the fly */
offset = argp->cookie; offset = argp->cookie;
resp->status = nfsd_readdir(rqstp, &argp->fh, &offset, resp->status = nfsd_readdir(rqstp, &argp->fh, &offset,
&resp->common, nfssvc_encode_entry); &resp->common, nfssvc_encode_entry);
resp->count = resp->buffer - argp->buffer; resp->count = resp->buffer - buffer;
if (resp->offset) if (resp->offset)
*resp->offset = htonl(offset); *resp->offset = htonl(offset);
......
...@@ -388,8 +388,6 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) ...@@ -388,8 +388,6 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p)
return 0; return 0;
args->cookie = ntohl(*p++); args->cookie = ntohl(*p++);
args->count = ntohl(*p++); args->count = ntohl(*p++);
args->count = min_t(u32, args->count, PAGE_SIZE);
args->buffer = page_address(*(rqstp->rq_next_page++));
return xdr_argsize_check(rqstp, p); return xdr_argsize_check(rqstp, p);
} }
......
...@@ -73,7 +73,6 @@ struct nfsd_readdirargs { ...@@ -73,7 +73,6 @@ struct nfsd_readdirargs {
struct svc_fh fh; struct svc_fh fh;
__u32 cookie; __u32 cookie;
__u32 count; __u32 count;
__be32 * buffer;
}; };
struct nfsd_stat { struct nfsd_stat {
......
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