diff mbox series

svcrdma: fix bounce buffers for non-zero page offsets

Message ID 20201002144827.984306-1-dan@kernelim.com (mailing list archive)
State Not Applicable
Headers show
Series svcrdma: fix bounce buffers for non-zero page offsets | expand

Commit Message

Dan Aloni Oct. 2, 2020, 2:48 p.m. UTC
This was discovered using O_DIRECT and small unaligned file offsets
at the client side.

Fixes: e248aa7be86 ("svcrdma: Remove max_sge check at connect time")
Signed-off-by: Dan Aloni <dan@kernelim.com>
---
 net/sunrpc/xprtrdma/svc_rdma_sendto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chuck Lever III Oct. 2, 2020, 2:54 p.m. UTC | #1
Hi Dan-

> On Oct 2, 2020, at 10:48 AM, Dan Aloni <dan@kernelim.com> wrote:
> 
> This was discovered using O_DIRECT and small unaligned file offsets
> at the client side.
> 
> Fixes: e248aa7be86 ("svcrdma: Remove max_sge check at connect time")
> Signed-off-by: Dan Aloni <dan@kernelim.com>
> ---
> net/sunrpc/xprtrdma/svc_rdma_sendto.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> index 7b94d971feb3..c991eb1fd4e3 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> @@ -638,7 +638,7 @@ static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma,
> 		while (remaining) {
> 			len = min_t(u32, PAGE_SIZE - pageoff, remaining);
> 
> -			memcpy(dst, page_address(*ppages), len);
> +			memcpy(dst, page_address(*ppages) + pageoff, len);

I'm assuming the only relevant place that sets xdr->page_base
is nfsd_splice_actor() ?


> 			remaining -= len;
> 			dst += len;
> 			pageoff = 0;
> -- 
> 2.26.2
> 

--
Chuck Lever
Dan Aloni Oct. 2, 2020, 3:18 p.m. UTC | #2
On Fri, Oct 02, 2020 at 10:54:28AM -0400, Chuck Lever wrote:
> Hi Dan-
> 
> > On Oct 2, 2020, at 10:48 AM, Dan Aloni <dan@kernelim.com> wrote:
> > 
> > This was discovered using O_DIRECT and small unaligned file offsets
> > at the client side.
> > 
> > Fixes: e248aa7be86 ("svcrdma: Remove max_sge check at connect time")
> > Signed-off-by: Dan Aloni <dan@kernelim.com>
> > ---
> > net/sunrpc/xprtrdma/svc_rdma_sendto.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> > index 7b94d971feb3..c991eb1fd4e3 100644
> > --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> > +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> > @@ -638,7 +638,7 @@ static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma,
> > 		while (remaining) {
> > 			len = min_t(u32, PAGE_SIZE - pageoff, remaining);
> > 
> > -			memcpy(dst, page_address(*ppages), len);
> > +			memcpy(dst, page_address(*ppages) + pageoff, len);
> 
> I'm assuming the only relevant place that sets xdr->page_base
> is nfsd_splice_actor() ?

Yes, and traces at the server indeed indicate that splicing happened.
This works for both tmpfs and ext4 as host FSes.
Chuck Lever III Oct. 2, 2020, 3:23 p.m. UTC | #3
> On Oct 2, 2020, at 11:18 AM, Dan Aloni <dan@kernelim.com> wrote:
> 
> On Fri, Oct 02, 2020 at 10:54:28AM -0400, Chuck Lever wrote:
>> Hi Dan-
>> 
>>> On Oct 2, 2020, at 10:48 AM, Dan Aloni <dan@kernelim.com> wrote:
>>> 
>>> This was discovered using O_DIRECT and small unaligned file offsets
>>> at the client side.
>>> 
>>> Fixes: e248aa7be86 ("svcrdma: Remove max_sge check at connect time")
>>> Signed-off-by: Dan Aloni <dan@kernelim.com>
>>> ---
>>> net/sunrpc/xprtrdma/svc_rdma_sendto.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
>>> index 7b94d971feb3..c991eb1fd4e3 100644
>>> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
>>> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
>>> @@ -638,7 +638,7 @@ static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma,
>>> 		while (remaining) {
>>> 			len = min_t(u32, PAGE_SIZE - pageoff, remaining);
>>> 
>>> -			memcpy(dst, page_address(*ppages), len);
>>> +			memcpy(dst, page_address(*ppages) + pageoff, len);
>> 
>> I'm assuming the only relevant place that sets xdr->page_base
>> is nfsd_splice_actor() ?
> 
> Yes, and traces at the server indeed indicate that splicing happened.
> This works for both tmpfs and ext4 as host FSes.

Seems plausible, thanks. I'll throw it into my test environment.


--
Chuck Lever
diff mbox series

Patch

diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index 7b94d971feb3..c991eb1fd4e3 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -638,7 +638,7 @@  static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma,
 		while (remaining) {
 			len = min_t(u32, PAGE_SIZE - pageoff, remaining);
 
-			memcpy(dst, page_address(*ppages), len);
+			memcpy(dst, page_address(*ppages) + pageoff, len);
 			remaining -= len;
 			dst += len;
 			pageoff = 0;