public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH 3/3] NFS: Avoid copy of xdr padding in read()
Date: Wed, 18 Nov 2020 17:19:39 -0500	[thread overview]
Message-ID: <20201118221939.20715-3-trondmy@kernel.org> (raw)
In-Reply-To: <20201118221939.20715-2-trondmy@kernel.org>

From: Trond Myklebust <trond.myklebust@hammerspace.com>

When doing a read() into a page, we also don't care if the nul padding
stays in that last page when the data length is not 32-bit aligned.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs2xdr.c | 2 +-
 fs/nfs/nfs3xdr.c | 2 +-
 fs/nfs/nfs4xdr.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index db9c265ad9e1..468bfbfe44d7 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -102,7 +102,7 @@ static int decode_nfsdata(struct xdr_stream *xdr, struct nfs_pgio_res *result)
 	if (unlikely(!p))
 		return -EIO;
 	count = be32_to_cpup(p);
-	recvd = xdr_read_pages(xdr, count);
+	recvd = xdr_read_pages(xdr, xdr_align_size(count));
 	if (unlikely(count > recvd))
 		goto out_cheating;
 out:
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index d3e1726d538b..8ef7c961d3e2 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1611,7 +1611,7 @@ static int decode_read3resok(struct xdr_stream *xdr,
 	ocount = be32_to_cpup(p++);
 	if (unlikely(ocount != count))
 		goto out_mismatch;
-	recvd = xdr_read_pages(xdr, count);
+	recvd = xdr_read_pages(xdr, xdr_align_size(count));
 	if (unlikely(count > recvd))
 		goto out_cheating;
 out:
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 755b556e85c3..5baa767106dc 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -5202,7 +5202,7 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req,
 		return -EIO;
 	eof = be32_to_cpup(p++);
 	count = be32_to_cpup(p);
-	recvd = xdr_read_pages(xdr, count);
+	recvd = xdr_read_pages(xdr, xdr_align_size(count));
 	if (count > recvd) {
 		dprintk("NFS: server cheating in read reply: "
 				"count %u > recvd %u\n", count, recvd);
-- 
2.28.0


  reply	other threads:[~2020-11-18 22:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 22:19 [PATCH 1/3] NFSv4: Fix the alignment of page data in the getdeviceinfo reply trondmy
2020-11-18 22:19 ` [PATCH 2/3] NFS: Avoid copy of xdr padding in readlink, layoutget and getxattr trondmy
2020-11-18 22:19   ` trondmy [this message]
2020-11-19 14:17     ` [PATCH 3/3] NFS: Avoid copy of xdr padding in read() Chuck Lever
2020-11-19 14:30       ` Trond Myklebust
2020-11-19 14:31         ` Chuck Lever
2020-11-19 14:34           ` Trond Myklebust
2020-11-19 22:58             ` Chuck Lever
2020-11-20  0:58               ` Trond Myklebust
2020-11-20 14:52                 ` Chuck Lever
2020-11-20 17:14                   ` Trond Myklebust
2020-11-20 17:51                     ` Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201118221939.20715-3-trondmy@kernel.org \
    --to=trondmy@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox