From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0547FC33C9E for ; Fri, 17 Jan 2020 21:46:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFD4F2072B for ; Fri, 17 Jan 2020 21:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbgAQVqP (ORCPT ); Fri, 17 Jan 2020 16:46:15 -0500 Received: from fieldses.org ([173.255.197.46]:34008 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbgAQVqP (ORCPT ); Fri, 17 Jan 2020 16:46:15 -0500 Received: by fieldses.org (Postfix, from userid 2815) id D64511C84; Fri, 17 Jan 2020 16:46:14 -0500 (EST) Date: Fri, 17 Jan 2020 16:46:14 -0500 From: "J. Bruce Fields" To: Chuck Lever Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH RFC] nfsd: Fix NFSv4 READ on RDMA when using readv Message-ID: <20200117214614.GC27294@fieldses.org> References: <20200115202647.2172.666.stgit@bazille.1015granger.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200115202647.2172.666.stgit@bazille.1015granger.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Jan 15, 2020 at 03:37:33PM -0500, Chuck Lever wrote: > svcrdma expects that the READ payload falls precisely into the > xdr_buf's page vector. Adding "xdr->iov = NULL" forces > xdr_reserve_space() to always use pages from xdr->buf->pages when > calling nfsd_readv. > > Also, the XDR padding is problematic. For NFS/RDMA Write chunks, > the padding needs to be in xdr->buf->tail so that the transport can > skip over it. However for NFS/TCP and the NFS/RDMA Reply chunks, > the padding has to be retained. Not yet sure how to add this. > > Fixes: b04209806384 ("nfsd4: allow exotic read compounds") > Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=198053 > Signed-off-by: Chuck Lever > --- > Howdy Bruce- > > I'm struggling with nfsd4_encode_readv(). > > - for NFS/RDMA Write chunks, the READ payload has to be in > buf->pages. I've fixed that. > > - xdr_reserve_space() calls don't need to explicitly align the > @nbytes argument: xdr_reserve_space() already does this? > > - the while loop probably won't work if a later READ in the COMPOUND > doesn't start on a page boundary. This isn't a problem until we > run into a Solaris client in forcedirectio mode. So the Solaris client sends multiple reads per compound in that case? > - the XDR padding doesn't work for NFS/RDMA Write chunks, which are > supposed to skip padding altogether. krb5i/p has to treat read data as padded regardless of the transport, doesn't it? --b. > Do you have suggestions? Thanks in advance. > > > fs/nfsd/nfs4xdr.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index d2dc4c0e22e8..14c68a136b4e 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -3519,17 +3519,14 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, > u32 zzz = 0; > int pad; > > + /* Ensure xdr_reserve_space behaves itself */ > + if (xdr->iov == xdr->buf->head) { > + xdr->iov = NULL; > + xdr->end = xdr->p; > + } > + > len = maxcount; > v = 0; > - > - thislen = min_t(long, len, ((void *)xdr->end - (void *)xdr->p)); > - p = xdr_reserve_space(xdr, (thislen+3)&~3); > - WARN_ON_ONCE(!p); > - resp->rqstp->rq_vec[v].iov_base = p; > - resp->rqstp->rq_vec[v].iov_len = thislen; > - v++; > - len -= thislen; > - > while (len) { > thislen = min_t(long, len, PAGE_SIZE); > p = xdr_reserve_space(xdr, (thislen+3)&~3); > @@ -3548,7 +3545,7 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, > read->rd_length = maxcount; > if (nfserr) > return nfserr; > - xdr_truncate_encode(xdr, starting_len + 8 + ((maxcount+3)&~3)); > + xdr_truncate_encode(xdr, starting_len + 8 + maxcount); > > tmp = htonl(eof); > write_bytes_to_xdr_buf(xdr->buf, starting_len , &tmp, 4);