* [PATCH v2 1/2] nfsd: Fixes for nfsd4_encode_read_plus_data()
@ 2020-12-11 17:26 trondmy
2020-12-11 17:26 ` [PATCH v2 2/2] nfsd: Don't set eof on a truncated READ_PLUS trondmy
0 siblings, 1 reply; 2+ messages in thread
From: trondmy @ 2020-12-11 17:26 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Ensure that we encode the data payload + padding, and that we truncate
the preallocated buffer to the actual read size.
Fixes: 528b84934eb9 ("NFSD: Add READ_PLUS data support")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfsd/nfs4xdr.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 833a2c64dfe8..26f6e277101d 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4632,6 +4632,7 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp,
resp->rqstp->rq_vec, read->rd_vlen, maxcount, eof);
if (nfserr)
return nfserr;
+ xdr_truncate_encode(xdr, starting_len + 16 + xdr_align_size(*maxcount));
tmp = htonl(NFS4_CONTENT_DATA);
write_bytes_to_xdr_buf(xdr->buf, starting_len, &tmp, 4);
@@ -4639,6 +4640,10 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp,
write_bytes_to_xdr_buf(xdr->buf, starting_len + 4, &tmp64, 8);
tmp = htonl(*maxcount);
write_bytes_to_xdr_buf(xdr->buf, starting_len + 12, &tmp, 4);
+
+ tmp = xdr_zero;
+ write_bytes_to_xdr_buf(xdr->buf, starting_len + 16 + *maxcount, &tmp,
+ xdr_pad_size(*maxcount));
return nfs_ok;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2 2/2] nfsd: Don't set eof on a truncated READ_PLUS
2020-12-11 17:26 [PATCH v2 1/2] nfsd: Fixes for nfsd4_encode_read_plus_data() trondmy
@ 2020-12-11 17:26 ` trondmy
0 siblings, 0 replies; 2+ messages in thread
From: trondmy @ 2020-12-11 17:26 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
If the READ_PLUS operation was truncated due to an error, then ensure we
clear the 'eof' flag.
Fixes: 9f0b5792f07d ("NFSD: Encode a full READ_PLUS reply")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfsd/nfs4xdr.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 26f6e277101d..5f5169b9c2e9 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4736,14 +4736,15 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr,
if (nfserr && segments == 0)
xdr_truncate_encode(xdr, starting_len);
else {
- tmp = htonl(eof);
- write_bytes_to_xdr_buf(xdr->buf, starting_len, &tmp, 4);
- tmp = htonl(segments);
- write_bytes_to_xdr_buf(xdr->buf, starting_len + 4, &tmp, 4);
if (nfserr) {
xdr_truncate_encode(xdr, last_segment);
nfserr = nfs_ok;
+ eof = 0;
}
+ tmp = htonl(eof);
+ write_bytes_to_xdr_buf(xdr->buf, starting_len, &tmp, 4);
+ tmp = htonl(segments);
+ write_bytes_to_xdr_buf(xdr->buf, starting_len + 4, &tmp, 4);
}
return nfserr;
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-11 19:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-11 17:26 [PATCH v2 1/2] nfsd: Fixes for nfsd4_encode_read_plus_data() trondmy
2020-12-11 17:26 ` [PATCH v2 2/2] nfsd: Don't set eof on a truncated READ_PLUS trondmy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox