Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3250308iob; Mon, 16 May 2022 17:08:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAl2C7k6APE6of0XZhMtf7KSCX8YA/3wgZ4eF6zmd+CeiKgQRogL3okn6LoTJy5PnFZvtG X-Received: by 2002:a05:6402:5190:b0:427:f1c8:a897 with SMTP id q16-20020a056402519000b00427f1c8a897mr16200219edd.52.1652746126788; Mon, 16 May 2022 17:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652746126; cv=none; d=google.com; s=arc-20160816; b=ZwQgabdQeYLwO5W+PAtwkFnLtw208RfiK1aL7yil1+QjvDq5XHxBd891QRYBwssdXM ErB7xQmSU96fDX710vRyUlP/eTe85fbLxBjerN49TE+GlXH7/T7LQO+mjKbMgQOYr6YG DXDp9Gc13Wv6Lg0z8OrItr8GhvOGzWqwMthWupt3NshyNRWlF3DoShMT0tGr2qYbrViE hfKtUGzFRqiHdChP83BNRuYoUbAENKZ++BahTIP2sp965uGGijLNWYkQBKHBnPuQW+kO POb02YFuL7niE+6R0j8keZ0OKxZoaZoAaqI5D0QFJvOfUIJZOZ5+62IdK+BmBNa5MY+O Ek2A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2DRoSaIka96sRV+HU2MNEj4QN0ZpSRC+jdalBNRVvoc=; b=Iffn8/MxAyrPJmBmpWknqFExRUuoQ09Zy6makggXHHuwz4iofls3Xq775ihyOoHdx6 USO3VxvACB9u67CGdSL4KgcwVH7zcvoZ0SF3dRaLTsK74gbgwobja7PWyeL+f3yCquDa wTdaQzVZ86qz8Ph5ciWuL3VG6rXEguo79UGx5x9APlj1MKaH+MFnuulcSF6Vea9GPh0s mh7rB5dRsPmY7akM7LZi9hvjEPUQKFzY8GPCT8krbnnVVIP4SaEA3Dy97Q+rv4vGLXay ZQtP+fnVBrcOkBUnCO54B+AZKO++iYn0KMpd/P5ggokzNt1LU2jIUMSYfSE/J0frP2vr U2WQ== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=netapp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a056402425000b0041d70e3a2b0si13395755edb.55.2022.05.16.17.08.17; Mon, 16 May 2022 17:08:46 -0700 (PDT) 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=netapp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346609AbiEPVBj (ORCPT + 99 others); Mon, 16 May 2022 17:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348960AbiEPVBA (ORCPT ); Mon, 16 May 2022 17:01:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3FBD2BD2 for ; Mon, 16 May 2022 13:35:55 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 28606B8165E for ; Mon, 16 May 2022 20:35:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EAD7C385AA; Mon, 16 May 2022 20:35:52 +0000 (UTC) From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v1 4/6] SUNRPC: Introduce xdr_buf_nth_page_address() Date: Mon, 16 May 2022 16:35:47 -0400 Message-Id: <20220516203549.2605575-5-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516203549.2605575-1-Anna.Schumaker@Netapp.com> References: <20220516203549.2605575-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, T_SCC_BODY_TEXT_LINE 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 From: Anna Schumaker For getting a pointer to the memory address represented by the nth page, along with the length of the data on that page. Signed-off-by: Anna Schumaker --- include/linux/sunrpc/xdr.h | 2 ++ net/sunrpc/xdr.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 344c820484ba..b375b284afbe 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -137,6 +137,8 @@ void xdr_inline_pages(struct xdr_buf *, unsigned int, struct page **, unsigned int, unsigned int); void xdr_terminate_string(const struct xdr_buf *, const u32); size_t xdr_buf_pagecount(const struct xdr_buf *buf); +char *xdr_buf_nth_page_address(const struct xdr_buf *buf, unsigned int n, + unsigned int *len); int xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp); void xdr_free_bvec(struct xdr_buf *buf); diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 3ecc444b27be..0b378c80f5f5 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -140,6 +140,23 @@ size_t xdr_buf_pagecount(const struct xdr_buf *buf) return (buf->page_base + buf->page_len + PAGE_SIZE - 1) >> PAGE_SHIFT; } +char *xdr_buf_nth_page_address(const struct xdr_buf *buf, unsigned int n, + unsigned int *len) +{ + unsigned int pgbase = buf->page_base + (n * PAGE_SIZE); + struct page **pages = buf->pages; + struct page **page; + + if (n >= xdr_buf_pagecount(buf)) + return NULL; + + page = pages + (pgbase >> PAGE_SHIFT); + pgbase &= ~PAGE_MASK; + *len = min_t(size_t, PAGE_SIZE, buf->page_len - (n * PAGE_SIZE)); + return page_address(*page) + pgbase; +} +EXPORT_SYMBOL_GPL(xdr_buf_nth_page_address); + int xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp) { -- 2.36.1