Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/4] SUNRPC: Clean up xdr_write_pages()
Date: Mon, 12 Dec 2022 11:53:27 -0500	[thread overview]
Message-ID: <2f8af9190926ac682121a9c75808240fea0e580e.camel@kernel.org> (raw)
In-Reply-To: <166949612452.106845.16079864294324208424.stgit@klimt.1015granger.net>

On Sat, 2022-11-26 at 15:55 -0500, Chuck Lever wrote:
> Make it more evident how xdr_write_pages() updates the tail buffer
> by using the convention of naming the iov pointer variable "tail".
> I spent more than a couple of hours chasing through code to
> understand this, so someone is likely to find this useful later.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  net/sunrpc/xdr.c |   22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
> index 336a7c7833e4..f7767bf22406 100644
> --- a/net/sunrpc/xdr.c
> +++ b/net/sunrpc/xdr.c
> @@ -1224,30 +1224,34 @@ EXPORT_SYMBOL(xdr_restrict_buflen);
>  /**
>   * xdr_write_pages - Insert a list of pages into an XDR buffer for sending
>   * @xdr: pointer to xdr_stream
> - * @pages: list of pages
> - * @base: offset of first byte
> - * @len: length of data in bytes
> + * @pages: array of pages to insert
> + * @base: starting offset of first data byte in @pages
> + * @len: number of data bytes in @pages to insert
>   *
> + * After the @pages are added, the tail iovec is instantiated pointing to
> + * end of the head buffer, and the stream is set up to encode subsequent
> + * items into the tail.
>   */
>  void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, unsigned int base,
>  		 unsigned int len)
>  {
>  	struct xdr_buf *buf = xdr->buf;
> -	struct kvec *iov = buf->tail;
> +	struct kvec *tail = buf->tail;
> +
>  	buf->pages = pages;
>  	buf->page_base = base;
>  	buf->page_len = len;
>  
> -	iov->iov_base = (char *)xdr->p;
> -	iov->iov_len  = 0;
> -	xdr->iov = iov;
> +	tail->iov_base = xdr->p;
> +	tail->iov_len = 0;
> +	xdr->iov = tail;
>  
>  	if (len & 3) {
>  		unsigned int pad = 4 - (len & 3);
>  
>  		BUG_ON(xdr->p >= xdr->end);
> -		iov->iov_base = (char *)xdr->p + (len & 3);
> -		iov->iov_len  += pad;
> +		tail->iov_base = (char *)xdr->p + (len & 3);
> +		tail->iov_len += pad;
>  		len += pad;
>  		*xdr->p++ = 0;
>  	}
> 
> 

Reviewed-by: Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2022-12-12 16:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-26 20:55 [PATCH 0/4] quick NFSD-related clean-ups for 6.2 Chuck Lever
2022-11-26 20:55 ` [PATCH 1/4] SUNRPC: Don't leak netobj memory when gss_read_proxy_verf() fails Chuck Lever
2022-11-28 13:11   ` Jeff Layton
2022-11-28 14:02     ` Chuck Lever III
2022-11-28 14:13       ` Jeff Layton
2022-11-28 14:25         ` Chuck Lever III
2022-11-26 20:55 ` [PATCH 2/4] SUNRPC: Clean up xdr_write_pages() Chuck Lever
2022-12-12 16:53   ` Jeff Layton [this message]
2022-11-26 20:55 ` [PATCH 3/4] NFSD: Use only RQ_DROPME to signal the need to drop a reply Chuck Lever
2022-11-26 20:55 ` [PATCH 4/4] SUNRPC: Make the svc_authenticate tracepoint conditional Chuck Lever

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=2f8af9190926ac682121a9c75808240fea0e580e.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /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