Fixes for READ_PLUS
Subsystems (3)
v2 cover Fixes for READ_PLUS
From: Anna Schumaker <[email protected]>
These patches fix up hole and data segment decoding for READ_PLUS. It turns out I wasn't handling data getting truncated off the end of the message properly. These patches fix it up, and now xfstests generic/091 and generic/263 pass when run against servers exporting ext4 and btrfs. These tests also pass against servers exporting xfs when the clone operation is disabled, so it seems like there is something going on inside the xfs filesystem causing these tests to still fail.
- Changes since v1:
- Drop patch for allocating scratch page
- Drop patch for disabling READ_PLUS behind a Kconfig option
Thanks,
Anna
Anna Schumaker (2):
SUNRPC: Keep buf->len in sync with xdr->nwords when expanding holes
SUNRPC: Check if the buffer has fewer bytes than requested
net/sunrpc/xdr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.29.2
PATCH v2 1/2 SUNRPC: Keep buf->len in sync with xdr->nwords when expanding holes
From: Anna Schumaker <[email protected]>
Otherwise we could end up placing data a few bytes off from where we actually want to put it.
--- net/sunrpc/xdr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/xdr.c +2 -1
@@ -1314,6 +1314,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengtunsigned 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; }
Signature · 1 line
2.29.2
Re: [PATCH v2 1/2] SUNRPC: Keep buf->len in sync with xdr->nwords when expanding holes
Quoted 20 lines · On Dec 8, 2020, at 3:29 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
Otherwise we could end up placing data a few bytes off from where we actually want to put it.
Fixes 84ce182ab85b "SUNRPC: Add the ability to expand holes in data pages"Signed-off-by Anna Schumaker <[email protected]>---
net/sunrpc/xdr.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)net/sunrpc/xdr.c +0
-0
net/sunrpc/xdr.c uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengt · line 1317
Quoted 4 lines
net/sunrpc/xdr.c +1
-0@@ -1314,6 +1314,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengtunsigned 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);
If I understand what you're doing here correctly, the usual idiom is "XDR_QUADLEN(truncated) << 2" .
Quoted 15 lines
net/sunrpc/xdr.c +1
-1bytes -= 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; }Signature · 1 line
2.29.2
--
Chuck Lever
Re: [PATCH v2 1/2] SUNRPC: Keep buf->len in sync with xdr->nwords when expanding holes
Quoted 16 lines · Chuck Lever
Quoted 16 lines · On Dec 8, 2020, at 3:29 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
Otherwise we could end up placing data a few bytes off from where we actually want to put it.
Fixes 84ce182ab85b "SUNRPC: Add the ability to expand holes in data pages"Signed-off-by Anna Schumaker <[email protected]>---
net/sunrpc/xdr.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
net/sunrpc/xdr.c uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengt · line 1317
Quoted 9 lines
net/sunrpc/xdr.c +1
-0@@ -1314,6 +1314,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengtunsigned 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);If I understand what you're doing here correctly, the usual idiom is "
XDR_QUADLEN(truncated)<< 2" .
Oh, that works too. I'll adjust the patch. Thanks for letting me know!
Anna
Quoted 23 lines
Quoted 15 lines
net/sunrpc/xdr.c +1
-2bytes -= 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; } --Quoted 2 lines
2.29.2
--
Chuck Lever
Re: [PATCH v2 1/2] SUNRPC: Keep buf->len in sync with xdr->nwords when expanding holes
Quoted 34 lines · Anna Schumaker
Quoted 16 lines · Chuck Lever
Quoted 16 lines · On Dec 8, 2020, at 3:29 PM, [email protected] wrote:
From: Anna Schumaker <[email protected]>
Otherwise we could end up placing data a few bytes off from where we actually want to put it.
Fixes 84ce182ab85b "SUNRPC: Add the ability to expand holes in data pages"Signed-off-by Anna Schumaker <[email protected]>---
net/sunrpc/xdr.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)Quoted 12 lines
net/sunrpc/xdr.c uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengt · line 1317
Quoted 9 lines
net/sunrpc/xdr.c +1
-0@@ -1314,6 +1314,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengtunsigned 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);If I understand what you're doing here correctly, the usual idiom is "
XDR_QUADLEN(truncated)<< 2" .
Quoted 2 lines
Oh, that works too. I'll adjust the patch. Thanks for letting me know!
Urp, sorry. These days, the preferred mechanism is xdr_align_size(). Old habits die hard, I guess.
Quoted 22 lines
Anna
Quoted 20 lines
Quoted 15 lines
net/sunrpc/xdr.c +1
-2bytes -= 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; } --Quoted 2 lines
2.29.2
--
Chuck Lever
--
Chuck Lever
PATCH v2 2/2 SUNRPC: Check if the buffer has fewer bytes than requested
In reply to [email protected]From: Anna Schumaker <[email protected]>
xdr_expand_hole() might truncate data off the end of the buffer. If that happens, we need to return a short read to the NFS code to indicate that some data has been lost.
--- net/sunrpc/xdr.c | 2 ++ 1 file changed, 2 insertions(+)
net/sunrpc/xdr.c +2 -0
@@ -1273,6 +1273,8 @@ uint64_t xdr_align_data(struct xdr_stream *xdr, uint64_t offset, uint32_t length bytes = xdr->nwords <<2 ;if (length < bytes) bytes = length; +if (bytes < length) + length = bytes;/* Move page data to the left */ if (from > offset) {
Signature · 1 line
2.29.2