]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFSD: Update the NFSv2 READDIR result encoder to use struct xdr_stream
authorChuck Lever <chuck.lever@oracle.com>
Fri, 23 Oct 2020 20:49:01 +0000 (16:49 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 22 Mar 2021 14:18:59 +0000 (10:18 -0400)
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsxdr.c
fs/nfsd/xdr.h

index 8ae23ed6dc5db2aaa13ec152050ee99c2c15aa90..9522e5c5f49db7bbd67aeb9206cb81cd4e81aae9 100644 (file)
@@ -574,17 +574,21 @@ nfssvc_encode_readres(struct svc_rqst *rqstp, __be32 *p)
 int
 nfssvc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p)
 {
+       struct xdr_stream *xdr = &rqstp->rq_res_stream;
        struct nfsd_readdirres *resp = rqstp->rq_resp;
 
-       *p++ = resp->status;
-       if (resp->status != nfs_ok)
-               return xdr_ressize_check(rqstp, p);
-
-       xdr_ressize_check(rqstp, p);
-       p = resp->buffer;
-       *p++ = 0;                       /* no more entries */
-       *p++ = htonl((resp->common.err == nfserr_eof));
-       rqstp->rq_res.page_len = resp->count << 2;
+       if (!svcxdr_encode_stat(xdr, resp->status))
+               return 0;
+       switch (resp->status) {
+       case nfs_ok:
+               xdr_write_pages(xdr, &resp->page, 0, resp->count << 2);
+               /* no more entries */
+               if (xdr_stream_encode_item_absent(xdr) < 0)
+                       return 0;
+               if (xdr_stream_encode_bool(xdr, resp->common.err == nfserr_eof) < 0)
+                       return 0;
+               break;
+       }
 
        return 1;
 }
index 651de13e62fedf6c0500b085e4422b08791d46db..69a6efc71ecb550bbc87899ff0baefdd3d85e7ec 100644 (file)
@@ -114,6 +114,7 @@ struct nfsd_readdirres {
        __be32 *                buffer;
        int                     buflen;
        __be32 *                offset;
+       struct page             *page;
 };
 
 struct nfsd_statfsres {