]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSD: Fix returned READDIR offset cookie
authorChuck Lever <chuck.lever@oracle.com>
Tue, 10 Nov 2020 15:24:39 +0000 (10:24 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Jun 2024 12:52:51 +0000 (14:52 +0200)
[ Upstream commit 0a8f37fb34a96267c656f7254e69bb9a2fc89fe4 ]

Code inspection shows that the server's NFSv3 READDIR implementation
handles offset cookies slightly differently than the NFSv2 READDIR,
NFSv3 READDIRPLUS, and NFSv4 READDIR implementations,
and there doesn't seem to be any need for this difference.

As a clean up, I copied the logic from nfsd3_proc_readdirplus().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfsd/nfs3proc.c

index 71db0ed3c49ed810de083eb48f000e0502649fa2..8cffd9852ef043dc38f169d6bd8483d5faa6675d 100644 (file)
@@ -449,6 +449,7 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp)
        struct nfsd3_readdirargs *argp = rqstp->rq_argp;
        struct nfsd3_readdirres  *resp = rqstp->rq_resp;
        int             count = 0;
+       loff_t          offset;
        struct page     **p;
        caddr_t         page_addr = NULL;
 
@@ -467,7 +468,9 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp)
        resp->common.err = nfs_ok;
        resp->buffer = argp->buffer;
        resp->rqstp = rqstp;
-       resp->status = nfsd_readdir(rqstp, &resp->fh, (loff_t *)&argp->cookie,
+       offset = argp->cookie;
+
+       resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
                                    &resp->common, nfs3svc_encode_entry);
        memcpy(resp->verf, argp->verf, 8);
        count = 0;
@@ -483,8 +486,6 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp)
        }
        resp->count = count >> 2;
        if (resp->offset) {
-               loff_t offset = argp->cookie;
-
                if (unlikely(resp->offset1)) {
                        /* we ended up with offset on a page boundary */
                        *resp->offset = htonl(offset >> 32);