netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Trond Myklebust <trondmy@hammerspace.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"chuck.lever@oracle.com" <chuck.lever@oracle.com>,
	 "dhowells@redhat.com" <dhowells@redhat.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	 "tom@talpey.com" <tom@talpey.com>,
	"anna@kernel.org" <anna@kernel.org>,
	"kolga@netapp.com" <kolga@netapp.com>,
	"Dai.Ngo@oracle.com" <Dai.Ngo@oracle.com>,
	"neilb@suse.de" <neilb@suse.de>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	 "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sunrpc: account for xdr->page_base in xdr_alloc_bvec
Date: Mon, 14 Aug 2023 11:30:53 -0400	[thread overview]
Message-ID: <7c9421cc4b92dee76cc7560c50a4a0ab3fb1ef0d.camel@kernel.org> (raw)
In-Reply-To: <40adb882f4c809b8a404e167c05bbbc9a1de6fa0.camel@hammerspace.com>

On Mon, 2023-08-14 at 14:51 +0000, Trond Myklebust wrote:
> On Mon, 2023-08-14 at 10:32 -0400, Jeff Layton wrote:
> > I've been seeing a regression in mainline (v6.5-rc) kernels where
> > unaligned reads were returning corrupt data.
> > 
> > 9d96acbc7f37 added a routine to allocate and populate a bvec array
> > that
> > can be used to back an iov_iter. When it does this, it always sets
> > the
> > offset in the first bvec to zero, even when the xdr->page_base is
> > non-zero.
> > 
> > The old code in svc_tcp_sendmsg used to account for this, as it was
> > sending the pages one at a time anyway, but now that we just hand the
> > iov to the network layer, we need to ensure that the bvecs are
> > properly
> > initialized.
> > 
> > Fix xdr_alloc_bvec to set the offset in the first bvec to the offset
> > indicated by xdr->page_base, and then 0 in all subsequent bvecs.
> > 
> > Fixes: 9d96acbc7f37 ("SUNRPC: Add a bvec array to struct xdr_buf for
> > use with iovec_iter()")
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> > NB: This is only lightly tested so far, but it seems to fix the pynfs
> > regressions I've been seeing.
> > ---
> >  net/sunrpc/xdr.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
> > index 2a22e78af116..d0f5fc8605b8 100644
> > --- a/net/sunrpc/xdr.c
> > +++ b/net/sunrpc/xdr.c
> > @@ -144,6 +144,7 @@ int
> >  xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp)
> >  {
> >         size_t i, n = xdr_buf_pagecount(buf);
> > +       unsigned int offset = offset_in_page(buf->page_base);
> >  
> >         if (n != 0 && buf->bvec == NULL) {
> >                 buf->bvec = kmalloc_array(n, sizeof(buf->bvec[0]),
> > gfp);
> > @@ -151,7 +152,8 @@ xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp)
> >                         return -ENOMEM;
> >                 for (i = 0; i < n; i++) {
> >                         bvec_set_page(&buf->bvec[i], buf->pages[i],
> > PAGE_SIZE,
> > -                                     0);
> > +                                     offset);
> > +                       offset = 0;
> 
> NACK. That's going to break the client.
> 

<rant>
What's the point of setting up a bvec array that doesn't actually
describe the usable data?
</rant>

Sigh, ok...I suppose we'll need to fix this in the svc callers instead.

> >                 }
> >         }
> >         return 0;
> > 
> > ---
> > base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
> > change-id: 20230814-sendpage-b04874eed249
> > 
> > Best regards,
> 

-- 
Jeff Layton <jlayton@kernel.org>

      reply	other threads:[~2023-08-14 15:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 14:32 [PATCH] sunrpc: account for xdr->page_base in xdr_alloc_bvec Jeff Layton
2023-08-14 14:40 ` Jeff Layton
2023-08-14 14:51 ` Trond Myklebust
2023-08-14 15:30   ` Jeff Layton [this message]

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=7c9421cc4b92dee76cc7560c50a4a0ab3fb1ef0d.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=kolga@netapp.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tom@talpey.com \
    --cc=trondmy@hammerspace.com \
    /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).