Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp12661955rwb; Sat, 26 Nov 2022 13:01:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pOkgfELK0K9jVpa42rZSES7UJiouDMvuFUybQJM9vyJMQVKIlDLT5RVbU97L8Zfbmdc6v X-Received: by 2002:a63:5c0f:0:b0:470:8e8a:8e11 with SMTP id q15-20020a635c0f000000b004708e8a8e11mr21495165pgb.490.1669496488238; Sat, 26 Nov 2022 13:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669496488; cv=none; d=google.com; s=arc-20160816; b=Ax01m/6sM6ep6+n99aRWMunhpEMUFk12STaEkkKJkfkXKhsKdK/jwdfdpuvxSTi7+L jT6gTIXnYDwsuA0Rh+zNDor98KusZ3pPkGHxOpZDIUenKF8lSm9j9H2uX+7J23vSgleZ rjTjpxsXApdlhaIrQTXuXB38SG/cQZ+djosmupI48C+nWlgTSailhJyPo91PR+bfs2I2 R7o5+Rp9Qs8+HMPrfxgOO7i9mjzMIgCpv9+XYk22Vnwb6V7FmhuJ672ha0b5d3+2FMBy JhGq/UG+ac1sA6dp9HVPAB/s1Z7nl5acqlYnAFxTpeI5jNRSKPcVBzhYIZgsmnzmGUMK LbmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=EJdV4XGsU3fnxQ5JY2IlN9CQ5T3C6gLpCP8x/8HMQDU=; b=XYsBLfisE+5Y+BQ4aIc8lVx/WI86Ff3cSnbVrdAgdCxfHjp37SdHIkdv6XfivmSrSq 4qGnZygWlwgMZM6FCXVU3RFcejrsgM9NL0937hf7ME4r3AyUXgLQF80X41U5Hl1bdKnk Ftpt49qIdyt0eiyyR0GlsZQB8kKDqkCV45UWLA72k/AwNz6RGrVF0EPy4WVpgpU6eJdl Par/R3rk7jCU7Q2P7bUD/aymUf9/bb9srg/CK7p3/JLfiNkvy+ThnbTxhWH3WXcOYheU HysUVoB6w2tJg9Prz5CtYg0ndkHmqslE8DLSi4q0phpEUOEDu4wEhTq9p5Hh270D1QG4 j3/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f187-20020a6251c4000000b0056d097ca7efsi7052014pfb.37.2022.11.26.13.01.02; Sat, 26 Nov 2022 13:01:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbiKZUza (ORCPT + 99 others); Sat, 26 Nov 2022 15:55:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiKZUz3 (ORCPT ); Sat, 26 Nov 2022 15:55:29 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE3B17AA6 for ; Sat, 26 Nov 2022 12:55:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 53BEFCE0A4C for ; Sat, 26 Nov 2022 20:55:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73419C433D6 for ; Sat, 26 Nov 2022 20:55:25 +0000 (UTC) Subject: [PATCH 2/4] SUNRPC: Clean up xdr_write_pages() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Sat, 26 Nov 2022 15:55:24 -0500 Message-ID: <166949612452.106845.16079864294324208424.stgit@klimt.1015granger.net> In-Reply-To: <166949601705.106845.10614964159272504008.stgit@klimt.1015granger.net> References: <166949601705.106845.10614964159272504008.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev3+g9561319 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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; }