linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: schumaker.anna@gmail.com
To: linux-nfs@vger.kernel.org
Cc: Anna.Schumaker@Netapp.com
Subject: [PATCH 3/3] SUNRPC: Keep buf->len in sync with xdr->nwords when expanding holes
Date: Thu,  3 Dec 2020 15:18:41 -0500	[thread overview]
Message-ID: <20201203201841.103294-4-Anna.Schumaker@Netapp.com> (raw)
In-Reply-To: <20201203201841.103294-1-Anna.Schumaker@Netapp.com>

From: Anna Schumaker <Anna.Schumaker@Netapp.com>

Otherwise we could end up placing data a few bytes off from where we
actually want to put it.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
 net/sunrpc/xdr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 71e03b930b70..5b848fe65c81 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1314,6 +1314,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengt
 		unsigned int res = _shift_data_right_tail(buf, from + bytes - shift, shift);
 		truncated = shift - res;
 		xdr->nwords -= XDR_QUADLEN(truncated);
+		buf->len -= 4 * XDR_QUADLEN(truncated);
 		bytes -= shift;
 	}
 
@@ -1325,7 +1326,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengt
 					bytes);
 	_zero_pages(buf->pages, buf->page_base + offset, length);
 
-	buf->len += length - (from - offset) - truncated;
+	buf->len += length - (from - offset);
 	xdr_set_page(xdr, offset + length, PAGE_SIZE);
 	return length;
 }
-- 
2.29.2


  parent reply	other threads:[~2020-12-03 20:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 20:18 [PATCH 0/3] NFS: Disable READ_PLUS by default schumaker.anna
2020-12-03 20:18 ` [PATCH 1/3] " schumaker.anna
2020-12-03 20:18 ` [PATCH 2/3] NFS: Allocate a scratch page for READ_PLUS schumaker.anna
2020-12-03 20:27   ` Chuck Lever
2020-12-03 20:31     ` Anna Schumaker
2020-12-03 20:39       ` Trond Myklebust
2020-12-04 16:14         ` Chuck Lever
2020-12-03 20:18 ` schumaker.anna [this message]
2020-12-04 15:47 ` [PATCH 0/3] NFS: Disable READ_PLUS by default Mkrtchyan, Tigran
2020-12-04 20:00   ` Olga Kornievskaia
2020-12-04 22:50     ` Mkrtchyan, Tigran
2020-12-07 15:26       ` Mkrtchyan, Tigran
2020-12-07 15:54         ` Mkrtchyan, Tigran
2020-12-08 12:39           ` Mkrtchyan, Tigran
2020-12-08 13:38             ` Anna Schumaker
2020-12-09 18:23               ` Mkrtchyan, Tigran
2020-12-09 16:59     ` Trond Myklebust
2020-12-09 17:07       ` Olga Kornievskaia
2020-12-09 17:12         ` Trond Myklebust
2020-12-09 17:22           ` Olga Kornievskaia
2020-12-09 17:28             ` Anna Schumaker
2020-12-09 17:39               ` Olga Kornievskaia
2020-12-09 17:32             ` Trond Myklebust
2020-12-09 17:40               ` Olga Kornievskaia

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=20201203201841.103294-4-Anna.Schumaker@Netapp.com \
    --to=schumaker.anna@gmail.com \
    --cc=Anna.Schumaker@Netapp.com \
    --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;
as well as URLs for NNTP newsgroup(s).