From: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx> When doing a readlink, layoutget or getxattr call into an array of pages, we don't care if the XDR padding ends up in the last page when the data length is not 32-bit aligned. Avoid an unnecessary copy by just leaving that padding in place. Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx> --- fs/nfs/nfs2xdr.c | 2 +- fs/nfs/nfs3xdr.c | 2 +- fs/nfs/nfs42xdr.c | 2 +- fs/nfs/nfs4xdr.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index f6676af37d5d..db9c265ad9e1 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c @@ -437,7 +437,7 @@ static int decode_path(struct xdr_stream *xdr) length = be32_to_cpup(p); if (unlikely(length >= xdr->buf->page_len || length > NFS_MAXPATHLEN)) goto out_size; - recvd = xdr_read_pages(xdr, length); + recvd = xdr_read_pages(xdr, xdr_align_size(length)); if (unlikely(length > recvd)) goto out_cheating; xdr_terminate_string(xdr->buf, length); diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index 69971f6c840d..d3e1726d538b 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -234,7 +234,7 @@ static int decode_nfspath3(struct xdr_stream *xdr) count = be32_to_cpup(p); if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN)) goto out_nametoolong; - recvd = xdr_read_pages(xdr, count); + recvd = xdr_read_pages(xdr, xdr_align_size(count)); if (unlikely(count > recvd)) goto out_cheating; xdr_terminate_string(xdr->buf, count); diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 6e060a88f98c..e58bfe208ae8 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -495,7 +495,7 @@ static int decode_getxattr(struct xdr_stream *xdr, res->xattr_len = len; if (len > 0) { - rdlen = xdr_read_pages(xdr, len); + rdlen = xdr_read_pages(xdr, xdr_align_size(len)); if (rdlen < len) return -EIO; } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index c8714381d511..755b556e85c3 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -5250,7 +5250,7 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) dprintk("nfs: server returned giant symlink!\n"); return -ENAMETOOLONG; } - recvd = xdr_read_pages(xdr, len); + recvd = xdr_read_pages(xdr, xdr_align_size(len)); if (recvd < len) { dprintk("NFS: server cheating in readlink reply: " "count %u > recvd %u\n", len, recvd); @@ -5925,7 +5925,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, res->type, res->layoutp->len); - recvd = xdr_read_pages(xdr, res->layoutp->len); + recvd = xdr_read_pages(xdr, xdr_align_size(res->layoutp->len)); if (res->layoutp->len > recvd) { dprintk("NFS: server cheating in layoutget reply: " "layout len %u > recvd %u\n", -- 2.28.0