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

Message ID 20200129160952.3024.44348.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/nfsxdr.c |   20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

Patch
diff mbox series

diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index b51fe515f06f..06e3a021b87a 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -455,13 +455,7 @@  __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f
 
 	*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;
 }
 
@@ -475,13 +469,7 @@  __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f
 	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;
 }
 
@@ -494,8 +482,8 @@  __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f
 	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;
-
+	xdr_buf_set_pagelen(&rqstp->rq_res,
+			    (((unsigned long)p - 1) & ~PAGE_MASK) + 1);
 	return 1;
 }