]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFSD: Count bytes instead of pages in the NFSv2 READDIR encoder
authorChuck Lever <chuck.lever@oracle.com>
Fri, 13 Nov 2020 21:57:44 +0000 (16:57 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 22 Mar 2021 14:18:59 +0000 (10:18 -0400)
Clean up: Counting the bytes used by each returned directory entry
seems less brittle to me than trying to measure consumed pages after
the fact.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsproc.c
fs/nfsd/nfsxdr.c

index 5a0dd6e23c85c988025a08569f5457b565431a7c..1acff9f4aaf1f685bd5d864175db9eeba70972e7 100644 (file)
@@ -578,14 +578,12 @@ nfsd_proc_readdir(struct svc_rqst *rqstp)
        struct nfsd_readdirargs *argp = rqstp->rq_argp;
        struct nfsd_readdirres *resp = rqstp->rq_resp;
        loff_t          offset;
-       __be32          *buffer;
 
        dprintk("nfsd: READDIR  %s %d bytes at %d\n",
                SVCFH_fmt(&argp->fh),           
                argp->count, argp->cookie);
 
        nfsd_init_dirlist_pages(rqstp, resp, argp->count);
-       buffer = resp->buffer;
 
        resp->offset = NULL;
        resp->common.err = nfs_ok;
@@ -593,8 +591,6 @@ nfsd_proc_readdir(struct svc_rqst *rqstp)
        offset = argp->cookie;
        resp->status = nfsd_readdir(rqstp, &argp->fh, &offset,
                                    &resp->common, nfssvc_encode_entry);
-
-       resp->count = resp->buffer - buffer;
        nfssvc_encode_nfscookie(resp, offset);
 
        fh_put(&argp->fh);
index a87b21cfe0d03ecb0337a0fde3a0e72974970a9f..8ae23ed6dc5db2aaa13ec152050ee99c2c15aa90 100644 (file)
@@ -584,7 +584,7 @@ nfssvc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p)
        p = resp->buffer;
        *p++ = 0;                       /* no more entries */
        *p++ = htonl((resp->common.err == nfserr_eof));
-       rqstp->rq_res.page_len = (((unsigned long)p-1) & ~PAGE_MASK)+1;
+       rqstp->rq_res.page_len = resp->count << 2;
 
        return 1;
 }
@@ -667,6 +667,7 @@ nfssvc_encode_entry(void *ccdv, const char *name,
        cd->offset = p;                 /* remember pointer */
        *p++ = htonl(~0U);              /* offset of next entry */
 
+       cd->count += p - cd->buffer;
        cd->buflen = buflen;
        cd->buffer = p;
        cd->common.err = nfs_ok;