[RFC,6/8] NFSD: NFSv3 support for automated padding of xdr_buf::pages
diff mbox series

Message ID 20200129160958.3024.25842.stgit@bazille.1015granger.net
State New
Headers show
Series
  • For discussion of bug 198053
Related show

Commit Message

Chuck Lever Jan. 29, 2020, 4:09 p.m. UTC
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs3xdr.c |   19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

Patch
diff mbox series

diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 195ab7a0fc89..91d96a329033 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -709,13 +709,7 @@  void fill_post_wcc(struct svc_fh *fhp)
 	if (resp->status == 0) {
 		*p++ = htonl(resp->len);
 		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);
-		}
+		xdr_buf_set_pagelen(&rqstp->rq_res, resp->len);
 		return 1;
 	} else
 		return xdr_ressize_check(rqstp, p);
@@ -733,14 +727,7 @@  void fill_post_wcc(struct svc_fh *fhp)
 		*p++ = htonl(resp->eof);
 		*p++ = htonl(resp->count);	/* xdr opaque count */
 		xdr_ressize_check(rqstp, p);
-		/* now update rqstp->rq_res to reflect data as well */
-		rqstp->rq_res.page_len = resp->count;
-		if (resp->count & 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->count & 3);
-		}
+		xdr_buf_set_pagelen(&rqstp->rq_res, resp->count);
 		return 1;
 	} else
 		return xdr_ressize_check(rqstp, p);
@@ -817,7 +804,7 @@  void fill_post_wcc(struct svc_fh *fhp)
 		xdr_ressize_check(rqstp, p);
 		if (rqstp->rq_res.head[0].iov_len + (2<<2) > PAGE_SIZE)
 			return 1; /*No room for trailer */
-		rqstp->rq_res.page_len = (resp->count) << 2;
+		xdr_buf_set_pagelen(&rqstp->rq_res, resp->count << 2);
 
 		/* add the 'tail' to the end of the 'head' page - page 0. */
 		rqstp->rq_res.tail[0].iov_base = p;