From patchwork Mon Sep 28 17:09:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67D1F618 for ; Mon, 28 Sep 2020 17:09:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CAE820757 for ; Mon, 28 Sep 2020 17:09:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RQ44dFuD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726565AbgI1RJY (ORCPT ); Mon, 28 Sep 2020 13:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgI1RJY (ORCPT ); Mon, 28 Sep 2020 13:09:24 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 058CFC061755 for ; Mon, 28 Sep 2020 10:09:23 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id o5so1627440qke.12 for ; Mon, 28 Sep 2020 10:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yIJ1AoId/iaH9uX+tiP3R4juFL9vJPxpeCdCSjsOFHw=; b=RQ44dFuDTB4NHpx2ocnxAkBzdnvKl/Qg+Dg27CgSgJWj4ny/OdHgYDapJHOFvGCx2O 00l7s/KI9mHpKGLZ1drPfBG8jSDOTSRGe6DDuAaH54DOP/zWfoWRArpvYuSlXL5OZ1rY BCZqJLRCeyjOOoB0USepyQ7DGWtdpEchpzefNT6Kn20p0Xg5J/upOSSS/2UfmJmgPUIH juK1PngmaFbZQGCDsC90s5vs20RAVTzA6WyoCF6CU/k/L252RgAJGisdZVpPlFZ3JIYN cKp2m5xmDzLYsN8djXpgGcwtpDkZFkXL17QY21EpSV6Ak/A+wf/X0LcAvidycfERRWRT u4eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yIJ1AoId/iaH9uX+tiP3R4juFL9vJPxpeCdCSjsOFHw=; b=IJnhr6MRoBhREhfkGKQSyerdmy1NC3WMCYC5yKWR4OXFE4BZosfXDuQyL1/mTBC0vc wZ23iopCU02xkHr22rTTWE+AdmRIMSHrYhF/Dm0FxTgxcvXJchTCYVGGT6ZG79d1wAAQ bCoaspmlCSBlh0QDmTmdnDa9flGZSEW8dryAFVT+PPiivi6ldbKTwCBN9NF3kJElO6X8 WDYjeqIMCHGgGQK0rEpuONwMCx4KClkSXhj9BgU63A5eU91zq4gOWhN3ZQMj2cuKXHW3 BCUkaGYDT8iAl328AQor1HDiQ0mHTm6XFGaVCQBMm1SSEZ20YJNx414KAB4LrBvZ4S/L LxNg== X-Gm-Message-State: AOAM531ku6MVT9UNBCcKSav079iGWJr1psCQ8+BtqNIVDec8vQhClVLj QZYoVFdO5xiPUcq0hQ3IGK14vH2GpU0= X-Google-Smtp-Source: ABdhPJxYgDn9/kurpV37H4cpt0gHrkUkl6LfOCQ4uerlzCrDXVl3K/GOrWPlojszZtijy9Uh3iO8Zg== X-Received: by 2002:a37:8ac2:: with SMTP id m185mr467323qkd.84.1601312961694; Mon, 28 Sep 2020 10:09:21 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:21 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 01/10] SUNRPC: Split out a function for setting current page Date: Mon, 28 Sep 2020 13:09:10 -0400 Message-Id: <20200928170919.707641-2-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker I'm going to need this bit of code in a few places for READ_PLUS decoding, so let's make it a helper function. Signed-off-by: Anna Schumaker --- net/sunrpc/xdr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 6dfe5dc8b35f..c62b0882c0d8 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -870,6 +870,13 @@ static int xdr_set_page_base(struct xdr_stream *xdr, return 0; } +static void xdr_set_page(struct xdr_stream *xdr, unsigned int base, + unsigned int len) +{ + if (xdr_set_page_base(xdr, base, len) < 0) + xdr_set_iov(xdr, xdr->buf->tail, xdr->nwords << 2); +} + static void xdr_set_next_page(struct xdr_stream *xdr) { unsigned int newbase; @@ -877,8 +884,7 @@ static void xdr_set_next_page(struct xdr_stream *xdr) newbase = (1 + xdr->page_ptr - xdr->buf->pages) << PAGE_SHIFT; newbase -= xdr->buf->page_base; - if (xdr_set_page_base(xdr, newbase, PAGE_SIZE) < 0) - xdr_set_iov(xdr, xdr->buf->tail, xdr->nwords << 2); + xdr_set_page(xdr, newbase, PAGE_SIZE); } static bool xdr_set_next_buffer(struct xdr_stream *xdr) @@ -886,8 +892,7 @@ static bool xdr_set_next_buffer(struct xdr_stream *xdr) if (xdr->page_ptr != NULL) xdr_set_next_page(xdr); else if (xdr->iov == xdr->buf->head) { - if (xdr_set_page_base(xdr, 0, PAGE_SIZE) < 0) - xdr_set_iov(xdr, xdr->buf->tail, xdr->nwords << 2); + xdr_set_page(xdr, 0, PAGE_SIZE); } return xdr->p != xdr->end; } From patchwork Mon Sep 28 17:09:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C8866CA for ; Mon, 28 Sep 2020 17:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EE702100A for ; Mon, 28 Sep 2020 17:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UrjthepI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbgI1RJZ (ORCPT ); Mon, 28 Sep 2020 13:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgI1RJZ (ORCPT ); Mon, 28 Sep 2020 13:09:25 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11D0C061755 for ; Mon, 28 Sep 2020 10:09:24 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id g72so1636043qke.8 for ; Mon, 28 Sep 2020 10:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FifsME1ATOsJkuZC/VYkpO0dbUrlMefaE25nRi/x3mQ=; b=UrjthepIrFE/vJrAEYo70s+OZ+fOweZKmmD4Q98sOWup1kZPiOB/MciwlcE90RHss+ Pmegra+kjqGqrVUKRC7x0KpeoVL6MOpwyNvD+TgMuL/pcgbrKpeANEqiibvxf0NLX8pC AcujWN/StjGrj7+1oNrEFMoQDwi+UlAJ/jG+VUGVsxGNZHVMtDViA72vyHTcpYC+DOwD HayRnkvKgsG7VtBD2RXmYavP4WnJbqDtmvWdgcP474zIDaG9WTfBJkj1S2wtVZFig6aY xgkSXU1qADk8cYc+jGipfPs7Y0ZKDShIsNHm63CNNAlhM6mC27VlcKfd7jN2UXN4Zz2J eYgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FifsME1ATOsJkuZC/VYkpO0dbUrlMefaE25nRi/x3mQ=; b=RvJG+4NkTCNobGikgLjtzM0fwMkPfCI7OXZS3O57Iybjh7Qid5hA3SLO8AOMQo1Wga imjt5GQ4iiG7o8qQXBBVr6kMwfpcUHBQeA5l8GWCPsse+Sv/22Vo2/KQ/VHBE2ngd0BZ KOBwJ1jD5VymM3oBoYlGpjjeojcMgqL8+C6h6Tb8B4SP0nhmDf6dy2+qKgdKHf1ZG3t8 cPlL60XMT63juKm8fMgLlVMkZvemawf1hajVy2N42N97TNFpobpgnvFbnXzzb7TKERrG sWXZMYH/Y5ziMLLajmLm3CjO4xv+6niMfkaSpNf14nDbZLrce6mRCGYy+z3qfLlpkV1N Kqxg== X-Gm-Message-State: AOAM533FSUAZg1Y7+7XFl6nTSoICH56UJ6xfGHJDY/CEyZnZRWLSofPw jliaChgnY3HGCY4RekxqmeYD/E3IbQU= X-Google-Smtp-Source: ABdhPJyFzmNP6yl77mIVMjHBIP0kFxWR17GfT+BG5BdrkcpRM7Oh0vF4rKwWEiaZV6d8JfotsQavFw== X-Received: by 2002:ae9:e8c5:: with SMTP id a188mr456663qkg.204.1601312963191; Mon, 28 Sep 2020 10:09:23 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:22 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 02/10] SUNRPC: Implement a xdr_page_pos() function Date: Mon, 28 Sep 2020 13:09:11 -0400 Message-Id: <20200928170919.707641-3-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker I'll need this for READ_PLUS to help figure out the offset where page data is stored at, but it might also be useful for other things. Signed-off-by: Anna Schumaker --- include/linux/sunrpc/xdr.h | 1 + net/sunrpc/xdr.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 6613d96a3029..026edbd041d5 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -242,6 +242,7 @@ extern int xdr_restrict_buflen(struct xdr_stream *xdr, int newbuflen); extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, unsigned int base, unsigned int len); extern unsigned int xdr_stream_pos(const struct xdr_stream *xdr); +extern unsigned int xdr_page_pos(const struct xdr_stream *xdr); extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, struct rpc_rqst *rqst); extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index c62b0882c0d8..8d29450fdce5 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -505,6 +505,19 @@ unsigned int xdr_stream_pos(const struct xdr_stream *xdr) } EXPORT_SYMBOL_GPL(xdr_stream_pos); +/** + * xdr_page_pos - Return the current offset from the start of the xdr pages + * @xdr: pointer to struct xdr_stream + */ +unsigned int xdr_page_pos(const struct xdr_stream *xdr) +{ + unsigned int pos = xdr_stream_pos(xdr); + + WARN_ON(pos < xdr->buf->head[0].iov_len); + return pos - xdr->buf->head[0].iov_len; +} +EXPORT_SYMBOL_GPL(xdr_page_pos); + /** * xdr_init_encode - Initialize a struct xdr_stream for sending data. * @xdr: pointer to xdr_stream struct From patchwork Mon Sep 28 17:09:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A738692C for ; Mon, 28 Sep 2020 17:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 893012100A for ; Mon, 28 Sep 2020 17:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i0Pa6pUK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbgI1RJZ (ORCPT ); Mon, 28 Sep 2020 13:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgI1RJZ (ORCPT ); Mon, 28 Sep 2020 13:09:25 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E299C061755 for ; Mon, 28 Sep 2020 10:09:25 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id v123so1637915qkd.9 for ; Mon, 28 Sep 2020 10:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oKdjF8WLFZZ+KSDTD6l3iBs66HwWOk9NAZ/Pz47k1uk=; b=i0Pa6pUK+ngPXPw+vA3OOd5WVIxMZ41n093yv5aNwVBqrLOB99FktVf8Ehw6Nf/vW6 zb2yvMxMchTO3XgtoB0LGu5wBJcW82gknv/CMxEZT+OsGo44kZMJB+3sslCW8Zm21yqy hYrWKKYZuQ12hk6WmqfURSl2+nX66l2WYJ1QxSe60S7NcGJPomTiu5rUQIING0m+hiQf kxD9AIePXSESt2qg08leu2I4Krv6HpAuT0lFPDX/8YUKebCrny0S7t+hh2ucoXP6hlRQ Zd6GaUpdITDhu54eP+XIIW/DA4YZFth+fUUi5EdrUNURHV3LA2/oP/E1dtkvOtBViAju Hj5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=oKdjF8WLFZZ+KSDTD6l3iBs66HwWOk9NAZ/Pz47k1uk=; b=gKr/TtvTeBpjmf9rUp5y6gObdJsGsWSSbcUTDcIC/PuQD31xS1X0Ik89ShGXELv7WD vw8FpOdpMEnA5SuJwOa4pC1mpJ7XAs9CDwkKA/33m1kWcpAF3ZAnJnq7KM8FxDKLLsUr RQ8mYZQj1IXtFyZqhJL9AyOtuqlDL8TVMLFzlRUJbRjRY8DttbZAC6TGJUTEvmGSKD8a cLZZ19kfX8txxmTfoaWspaTc/+yhrdXYgT6iwoDF6wlveNMhq5pdjETPHKoI2iN5Xkjg va569s+wkP7cE9IJagwFv838oKmIUmCKBslzA3oBv3M51fOaWT8v/xuWg8SfBwVg6LjX BiMw== X-Gm-Message-State: AOAM5321uto5QFNJGb9YWiCuHDy7ACcV6A2cjzG2Mywh2Yuh+MSnJ4Vb h/L6n57ShXfqZcNrpeAzIwqlXZ1fP0M= X-Google-Smtp-Source: ABdhPJxFy8x8HMK839+7v4q1P6ge1NhRafTGeMgZpEdloEV0FnnQzDQQhHNA1s1WcD4kWznde1tcKQ== X-Received: by 2002:a37:51d5:: with SMTP id f204mr406137qkb.145.1601312964304; Mon, 28 Sep 2020 10:09:24 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:23 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 03/10] NFS: Use xdr_page_pos() in NFSv4 decode_getacl() Date: Mon, 28 Sep 2020 13:09:12 -0400 Message-Id: <20200928170919.707641-4-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Signed-off-by: Anna Schumaker --- fs/nfs/nfs4xdr.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 0b3510f62623..3336ea3407a0 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -5308,7 +5308,6 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, uint32_t attrlen, bitmap[3] = {0}; int status; - unsigned int pg_offset; res->acl_len = 0; if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) @@ -5316,9 +5315,6 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, xdr_enter_page(xdr, xdr->buf->page_len); - /* Calculate the offset of the page data */ - pg_offset = xdr->buf->head[0].iov_len; - if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) goto out; if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) @@ -5331,7 +5327,7 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, /* The bitmap (xdr len + bitmaps) and the attr xdr len words * are stored with the acl data to handle the problem of * variable length bitmaps.*/ - res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; + res->acl_data_offset = xdr_page_pos(xdr); res->acl_len = attrlen; /* Check for receive buffer overflow */ From patchwork Mon Sep 28 17:09:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA9CE618 for ; Mon, 28 Sep 2020 17:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3AC520757 for ; Mon, 28 Sep 2020 17:09:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VfKyHych" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726600AbgI1RJ1 (ORCPT ); Mon, 28 Sep 2020 13:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgI1RJ0 (ORCPT ); Mon, 28 Sep 2020 13:09:26 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5ABFC061755 for ; Mon, 28 Sep 2020 10:09:26 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id q5so1656677qkc.2 for ; Mon, 28 Sep 2020 10:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jsVtXpKHO18EDs0UaAVk8R2F9e5jvPGl+D5N+mJTcss=; b=VfKyHychvjUPcQV+WF3ntCD8hOvwfvgz93JaXrnK8wfnaXXGyL23d6JTbXJorzxaun xK61yxZ+vWD+QmSePZeIllX91b81ua6rnoanHGxca9G2Z1pkJimnKGbqOGVzroKTRzQ8 ZhnZyAYqwaGMzarnlpNrThi3mUpeRra6OLWzWtAnUPU0W50kr1Zc1/Q9laT7gSWyuXh4 vnECx6tKZQK1ugSF/DLrCgD6514kPFPQxzS/g5BB1KrgrVNUPzbD+rxr2Frmg678y9rL KUalE0QXpZqzGxIagxVPamtBOPc/C5In3zBZ1g9NINrz+bz7oEwc/pf89SOdXv0pAL4P XgmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jsVtXpKHO18EDs0UaAVk8R2F9e5jvPGl+D5N+mJTcss=; b=cMJsRa9WT4olrMxkGdA5cXr+NlDCzlYWuk/hDjhqluA+YiywjGA9ZTBRaJSRd8RM01 B+502GblJdF7Ll2+9dApZPXt5/WNZtX3OzNWMKVCmIu8iMOIo36L/6NIe0k/P34NuAr7 9wrOQOeiNKsGGRcRbVA+b3lHAlKInClt32tqByUNMHH02OuEuEgg85T1jiGU9VqiG7z1 vQVWUpiUBmCTSPUxhhWU2jWxnH1FmUTsGeYGViHLvDjkM4AF088QzqVyt53l9VM6cuSq 9rgEEsb3i4yLI+FOBMpV57ei6cMnwqbAtExDW6XhsRiITiaGsipPHrYr/dtwcXELU+WF jHcA== X-Gm-Message-State: AOAM530wt56DN29VrRC3kY7xpwPJVcoCT1NEuwSkQts+hNNmU57E5tmi w7flq/efgNK8uLCQVUTtB+QI0XcHsC4= X-Google-Smtp-Source: ABdhPJyzQ4dz8LAOY53o9Cbs0/1FIJSo/bcdiwb6dctEHjQxFdZ/gbxT04sTw8JC2TOsAvZCELHLBQ== X-Received: by 2002:a05:620a:21d1:: with SMTP id h17mr421125qka.466.1601312965493; Mon, 28 Sep 2020 10:09:25 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:24 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 04/10] NFS: Add READ_PLUS data segment support Date: Mon, 28 Sep 2020 13:09:13 -0400 Message-Id: <20200928170919.707641-5-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker This patch adds client support for decoding a single NFS4_CONTENT_DATA segment returned by the server. This is the simplest implementation possible, since it does not account for any hole segments in the reply. Signed-off-by: Anna Schumaker --- v6: Disable READ_PLUS on RDMA v5: Fix up for the xattr patches --- fs/nfs/nfs42xdr.c | 141 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4client.c | 2 + fs/nfs/nfs4proc.c | 43 +++++++++++- fs/nfs/nfs4xdr.c | 1 + include/linux/nfs4.h | 2 +- include/linux/nfs_fs_sb.h | 1 + include/linux/nfs_xdr.h | 2 +- 7 files changed, 187 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index cc50085e151c..930b4ca212c1 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -45,6 +45,15 @@ #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \ encode_fallocate_maxsz) #define decode_deallocate_maxsz (op_decode_hdr_maxsz) +#define encode_read_plus_maxsz (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + 3) +#define NFS42_READ_PLUS_SEGMENT_SIZE (1 /* data_content4 */ + \ + 2 /* data_info4.di_offset */ + \ + 2 /* data_info4.di_length */) +#define decode_read_plus_maxsz (op_decode_hdr_maxsz + \ + 1 /* rpr_eof */ + \ + 1 /* rpr_contents count */ + \ + NFS42_READ_PLUS_SEGMENT_SIZE) #define encode_seek_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + \ 2 /* offset */ + \ @@ -128,6 +137,14 @@ decode_putfh_maxsz + \ decode_deallocate_maxsz + \ decode_getattr_maxsz) +#define NFS4_enc_read_plus_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ + encode_putfh_maxsz + \ + encode_read_plus_maxsz) +#define NFS4_dec_read_plus_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ + decode_putfh_maxsz + \ + decode_read_plus_maxsz) #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ @@ -324,6 +341,16 @@ static void encode_deallocate(struct xdr_stream *xdr, encode_fallocate(xdr, args); } +static void encode_read_plus(struct xdr_stream *xdr, + const struct nfs_pgio_args *args, + struct compound_hdr *hdr) +{ + encode_op_hdr(xdr, OP_READ_PLUS, decode_read_plus_maxsz, hdr); + encode_nfs4_stateid(xdr, &args->stateid); + encode_uint64(xdr, args->offset); + encode_uint32(xdr, args->count); +} + static void encode_seek(struct xdr_stream *xdr, const struct nfs42_seek_args *args, struct compound_hdr *hdr) @@ -722,6 +749,28 @@ static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req, encode_nops(&hdr); } +/* + * Encode READ_PLUS request + */ +static void nfs4_xdr_enc_read_plus(struct rpc_rqst *req, + struct xdr_stream *xdr, + const void *data) +{ + const struct nfs_pgio_args *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->seq_args), + }; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->seq_args, &hdr); + encode_putfh(xdr, args->fh, &hdr); + encode_read_plus(xdr, args, &hdr); + + rpc_prepare_reply_pages(req, args->pages, args->pgbase, + args->count, hdr.replen); + encode_nops(&hdr); +} + /* * Encode SEEK request */ @@ -970,6 +1019,71 @@ static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *re return decode_op_hdr(xdr, OP_DEALLOCATE); } +static int decode_read_plus_data(struct xdr_stream *xdr, struct nfs_pgio_res *res, + uint32_t *eof) +{ + uint32_t count, recvd; + uint64_t offset; + __be32 *p; + + p = xdr_inline_decode(xdr, 8 + 4); + if (unlikely(!p)) + return -EIO; + + p = xdr_decode_hyper(p, &offset); + count = be32_to_cpup(p); + recvd = xdr_read_pages(xdr, count); + res->count += recvd; + + if (count > recvd) { + dprintk("NFS: server cheating in read reply: " + "count %u > recvd %u\n", count, recvd); + *eof = 0; + return 1; + } + + return 0; +} + +static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) +{ + uint32_t eof, segments, type; + int status; + __be32 *p; + + status = decode_op_hdr(xdr, OP_READ_PLUS); + if (status) + return status; + + p = xdr_inline_decode(xdr, 4 + 4); + if (unlikely(!p)) + return -EIO; + + eof = be32_to_cpup(p++); + segments = be32_to_cpup(p++); + if (segments == 0) + goto out; + + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + type = be32_to_cpup(p++); + if (type == NFS4_CONTENT_DATA) + status = decode_read_plus_data(xdr, res, &eof); + else + return -EINVAL; + + if (status) + return status; + if (segments > 1) + eof = 0; + +out: + res->eof = eof; + return 0; +} + static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) { int status; @@ -1146,6 +1260,33 @@ static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp, return status; } +/* + * Decode READ_PLUS request + */ +static int nfs4_xdr_dec_read_plus(struct rpc_rqst *rqstp, + struct xdr_stream *xdr, + void *data) +{ + struct nfs_pgio_res *res = data; + struct compound_hdr hdr; + int status; + + status = decode_compound_hdr(xdr, &hdr); + if (status) + goto out; + status = decode_sequence(xdr, &res->seq_res, rqstp); + if (status) + goto out; + status = decode_putfh(xdr); + if (status) + goto out; + status = decode_read_plus(xdr, res); + if (!status) + status = res->count; +out: + return status; +} + /* * Decode SEEK request */ diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index daacc78a3d48..be7915c861ce 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -1045,6 +1045,8 @@ static int nfs4_server_common_setup(struct nfs_server *server, server->caps |= server->nfs_client->cl_mvops->init_caps; if (server->flags & NFS_MOUNT_NORDIRPLUS) server->caps &= ~NFS_CAP_READDIRPLUS; + if (server->nfs_client->cl_proto == XPRT_TRANSPORT_RDMA) + server->caps &= ~NFS_CAP_READ_PLUS; /* * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower * authentication. diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 542961ffa529..1077e913aab6 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -70,6 +70,10 @@ #include "nfs4trace.h" +#ifdef CONFIG_NFS_V4_2 +#include "nfs42.h" +#endif /* CONFIG_NFS_V4_2 */ + #define NFSDBG_FACILITY NFSDBG_PROC #define NFS4_BITMASK_SZ 3 @@ -5259,28 +5263,60 @@ static bool nfs4_read_stateid_changed(struct rpc_task *task, return true; } +static bool nfs4_read_plus_not_supported(struct rpc_task *task, + struct nfs_pgio_header *hdr) +{ + struct nfs_server *server = NFS_SERVER(hdr->inode); + struct rpc_message *msg = &task->tk_msg; + + if (msg->rpc_proc == &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS] && + server->caps & NFS_CAP_READ_PLUS && task->tk_status == -ENOTSUPP) { + server->caps &= ~NFS_CAP_READ_PLUS; + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; + rpc_restart_call_prepare(task); + return true; + } + return false; +} + static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) { - dprintk("--> %s\n", __func__); if (!nfs4_sequence_done(task, &hdr->res.seq_res)) return -EAGAIN; if (nfs4_read_stateid_changed(task, &hdr->args)) return -EAGAIN; + if (nfs4_read_plus_not_supported(task, hdr)) + return -EAGAIN; if (task->tk_status > 0) nfs_invalidate_atime(hdr->inode); return hdr->pgio_done_cb ? hdr->pgio_done_cb(task, hdr) : nfs4_read_done_cb(task, hdr); } +#ifdef CONFIG_NFS_V4_2 +static void nfs42_read_plus_support(struct nfs_server *server, struct rpc_message *msg) +{ + if (server->caps & NFS_CAP_READ_PLUS) + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ_PLUS]; + else + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; +} +#else +static void nfs42_read_plus_support(struct nfs_server *server, struct rpc_message *msg) +{ + msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; +} +#endif /* CONFIG_NFS_V4_2 */ + static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr, struct rpc_message *msg) { hdr->timestamp = jiffies; if (!hdr->pgio_done_cb) hdr->pgio_done_cb = nfs4_read_done_cb; - msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; + nfs42_read_plus_support(NFS_SERVER(hdr->inode), msg); nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); } @@ -10202,7 +10238,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { | NFS_CAP_SEEK | NFS_CAP_LAYOUTSTATS | NFS_CAP_CLONE - | NFS_CAP_LAYOUTERROR, + | NFS_CAP_LAYOUTERROR + | NFS_CAP_READ_PLUS, .init_client = nfs41_init_client, .shutdown_client = nfs41_shutdown_client, .match_stateid = nfs41_match_stateid, diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 3336ea3407a0..c6dbfcae7517 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -7615,6 +7615,7 @@ const struct rpc_procinfo nfs4_procedures[] = { PROC42(SETXATTR, enc_setxattr, dec_setxattr), PROC42(LISTXATTRS, enc_listxattrs, dec_listxattrs), PROC42(REMOVEXATTR, enc_removexattr, dec_removexattr), + PROC42(READ_PLUS, enc_read_plus, dec_read_plus), }; static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index b8360be141da..9dc7eeac924f 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -551,13 +551,13 @@ enum { NFSPROC4_CLNT_LOOKUPP, NFSPROC4_CLNT_LAYOUTERROR, - NFSPROC4_CLNT_COPY_NOTIFY, NFSPROC4_CLNT_GETXATTR, NFSPROC4_CLNT_SETXATTR, NFSPROC4_CLNT_LISTXATTRS, NFSPROC4_CLNT_REMOVEXATTR, + NFSPROC4_CLNT_READ_PLUS, }; /* nfs41 types */ diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 7eae72a8762e..38e60ec742df 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -287,5 +287,6 @@ struct nfs_server { #define NFS_CAP_LAYOUTERROR (1U << 26) #define NFS_CAP_COPY_NOTIFY (1U << 27) #define NFS_CAP_XATTR (1U << 28) +#define NFS_CAP_READ_PLUS (1U << 29) #endif diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 0599efd57eb9..d63cb862d58e 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -657,7 +657,7 @@ struct nfs_pgio_args { struct nfs_pgio_res { struct nfs4_sequence_res seq_res; struct nfs_fattr * fattr; - __u32 count; + __u64 count; __u32 op_status; union { struct { From patchwork Mon Sep 28 17:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 736CE618 for ; Mon, 28 Sep 2020 17:09:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52C192076A for ; Mon, 28 Sep 2020 17:09:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ik6Tf1sq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbgI1RJ2 (ORCPT ); Mon, 28 Sep 2020 13:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgI1RJ2 (ORCPT ); Mon, 28 Sep 2020 13:09:28 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FB35C061755 for ; Mon, 28 Sep 2020 10:09:28 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id x201so1253200qkb.11 for ; Mon, 28 Sep 2020 10:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sDycQp4p8QqjhUNfybr06rjLzMrYS09sHrxbwDXOUcI=; b=ik6Tf1sqR+mUChedyUAeezbTX/bd5l5okjGXLXx7KXsNCGZs/CXrv3OGN/4mXU74KO 4rTTX4N3zrDdDG1HYUwbvLXqgps6mI+uKxZuL2SYCGER1TKE5oC4d7gw1fTSznlS1SW2 Lq8lZKttvzRBqOIqSKcrZuOfyBqzmFG4ljO4RAro0vkTAVOaDxRJ1RYBdu8IMG/CznxO DNKYxCZjDwmVddCVCsAHKu7coSKeYir/BuJiEwuZ5uJO0YfuS2BR26eV76pCZmv49jNs 10OcCYRSnKtb3QKvd4CaZGYFqyrakwtA2ovtdAQZeRzVhnu/6tZAnZCxa1Jr3kEL7cWU Y3SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=sDycQp4p8QqjhUNfybr06rjLzMrYS09sHrxbwDXOUcI=; b=LQwf6Vbluin+KodCN7TE1F5N1uKcTM7ZE1trTzGFWUSSF6QYGtoGFrDuDuksle6e8u Ut9UvFBp9pTAiO5PH+R+4127tGD4/KmmI2BI0IeXsNQumlBWVze5zWxqXO37NkIEijic 3vMP9SF9jlQpdSM4LZVbZvKKC1oMch/nV/ckpcnkeWqh2zcU9F75xOZL+n2/HanJrWap wg3nQ1VZmPTAc+2k9QChnDQNt5Awptwd5TgqvMpge8FuAZFOin+nPHo2FlKf9KRaTYMb ox6PEgQrGHDUqTjtpT/mqb/lst9f9yW1YBvvBgmu5uaT+ChzCoKlQpd6Os70PB4Vrpw8 srMQ== X-Gm-Message-State: AOAM531H9NC8bw1Fo8TlVM2oJADPHwS6UD4mJ2WVrCH64AvsxQbVu6r5 MPueL+lAF4lvgW+6eDZyJAvUmkJmkXs= X-Google-Smtp-Source: ABdhPJyi5q+EBDsxI61+6cM95cWTeOsnJrNN3DVEOCGrSqE1oESIEYdWBVe5BXOrkYaN+JOoqzEGkQ== X-Received: by 2002:a37:a207:: with SMTP id l7mr481217qke.64.1601312966697; Mon, 28 Sep 2020 10:09:26 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:25 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 05/10] SUNRPC: Split out xdr_realign_pages() from xdr_align_pages() Date: Mon, 28 Sep 2020 13:09:14 -0400 Message-Id: <20200928170919.707641-6-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker I don't need the entire align pages code for READ_PLUS, so split out the part I do need so I don't need to reimplement anything. Signed-off-by: Anna Schumaker --- net/sunrpc/xdr.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 8d29450fdce5..70efb35c119e 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -1042,26 +1042,33 @@ __be32 * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) } EXPORT_SYMBOL_GPL(xdr_inline_decode); -static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) +static void xdr_realign_pages(struct xdr_stream *xdr) { struct xdr_buf *buf = xdr->buf; - struct kvec *iov; - unsigned int nwords = XDR_QUADLEN(len); + struct kvec *iov = buf->head; unsigned int cur = xdr_stream_pos(xdr); unsigned int copied, offset; - if (xdr->nwords == 0) - return 0; - /* Realign pages to current pointer position */ - iov = buf->head; if (iov->iov_len > cur) { offset = iov->iov_len - cur; copied = xdr_shrink_bufhead(buf, offset); trace_rpc_xdr_alignment(xdr, offset, copied); xdr->nwords = XDR_QUADLEN(buf->len - cur); } +} +static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) +{ + struct xdr_buf *buf = xdr->buf; + unsigned int nwords = XDR_QUADLEN(len); + unsigned int cur = xdr_stream_pos(xdr); + unsigned int copied, offset; + + if (xdr->nwords == 0) + return 0; + + xdr_realign_pages(xdr); if (nwords > xdr->nwords) { nwords = xdr->nwords; len = nwords << 2; From patchwork Mon Sep 28 17:09:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BBDC6CA for ; Mon, 28 Sep 2020 17:09:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 011F02076A for ; Mon, 28 Sep 2020 17:09:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h8FzGESx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbgI1RJ3 (ORCPT ); Mon, 28 Sep 2020 13:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgI1RJ3 (ORCPT ); Mon, 28 Sep 2020 13:09:29 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA77BC061755 for ; Mon, 28 Sep 2020 10:09:28 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id f11so826878qvw.3 for ; Mon, 28 Sep 2020 10:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=igtPl6C6Gfbp4gxTezXs9k9ZWoIUbuf9BiavER35twk=; b=h8FzGESx18UfpAGrmm6E5iD3H2nQ6XEnfHNfMYQFwQRZlaDND6Jektvv93VeNdZyNJ N3lTanuhJYOed1X9UpIKfY4heAMT+Ec1u5LW3OABb3pAHnvLy2M6+hXAJUO0AMipP50Y DaSHpj6/9XNEQt9ar28Uk+AyLN9QrcUItM5zmY9YtQBhWSTdO59Dqs0BSAZ9nYT5w5eP CTDPr48OhzYxHDY3kZZQv2ckCLXcFrkmfGABB9zOWDN1eL0MdekwpZlnW5scgaEtCHvv levlYmjRt7wVzRzGkgxz/5248tLfdTGjiKf2QbHoxAnOLGwSc9ms+9UaMBJOrscu6CPD KIcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=igtPl6C6Gfbp4gxTezXs9k9ZWoIUbuf9BiavER35twk=; b=Xzt/j8CcgmKq+yI08senczxZen9j2VyWTAY5ar9TgaBo8LDXyr+O+dJIcRwskpYA/7 E5F6+ujqrcYNk9rb5Cm9oJzqSvE0UkZG7p7xKnfIQl55kBZT2usNyBUYconds6oZl2An xlz0GM51CaXmVak+FERbSp+B1u0t8YSvPFv07gCJZWYVI+buceQssxZwiIB4St6yyupO DlIxUKTNDPlGfWsI0h+UvlroXkSJ4wWEGIrjOUMaC5yQdmRDDFsrFI5piJ0c0LaNqYXL +R8yfwxMR64w7jUsbXwP69awOYBomzI42XuWg1KtxXxWZ3CNus9aqHeDhVck1zEo8LPp atuw== X-Gm-Message-State: AOAM532Z3F/KXPyOb//x8EHzbHEUUfemP7Mw4tvpSgqKw7iIzs/eEZ4P bCsCior9LlgEoY8x3dpGu+G0q5FcsZk= X-Google-Smtp-Source: ABdhPJxpuCnWLkGOFsPwB3P1TJu8MD99m0iFK/lHq5D3Fi0NRbyPSJN8j57oAvyGFYuNETZ2AGRyKA== X-Received: by 2002:a0c:c709:: with SMTP id w9mr558168qvi.26.1601312967648; Mon, 28 Sep 2020 10:09:27 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:27 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 06/10] SUNRPC: Split out _shift_data_right_tail() Date: Mon, 28 Sep 2020 13:09:15 -0400 Message-Id: <20200928170919.707641-7-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker xdr_shrink_pagelen() is very similar to what we need for hole expansion, so split out the common code into its own function that can be used by both functions. Signed-off-by: Anna Schumaker --- net/sunrpc/xdr.c | 68 +++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 70efb35c119e..d8c9555c6f2b 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -266,6 +266,46 @@ _shift_data_right_pages(struct page **pages, size_t pgto_base, } while ((len -= copy) != 0); } +static unsigned int +_shift_data_right_tail(struct xdr_buf *buf, unsigned int pgfrom, size_t len) +{ + struct kvec *tail = buf->tail; + unsigned int tailbuf_len; + unsigned int result = 0; + size_t copy; + + tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len; + + /* Shift the tail first */ + if (tailbuf_len != 0) { + unsigned int free_space = tailbuf_len - tail->iov_len; + + if (len < free_space) + free_space = len; + if (len > free_space) + len = free_space; + + tail->iov_len += free_space; + copy = len; + + if (tail->iov_len > len) { + char *p = (char *)tail->iov_base + len; + memmove(p, tail->iov_base, tail->iov_len - free_space); + result += tail->iov_len - free_space; + } else + copy = tail->iov_len; + + /* Copy from the inlined pages into the tail */ + _copy_from_pages((char *)tail->iov_base, + buf->pages, + buf->page_base + pgfrom, + copy); + result += copy; + } + + return result; +} + /** * _copy_to_pages * @pages: array of pages @@ -446,39 +486,13 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) static unsigned int xdr_shrink_pagelen(struct xdr_buf *buf, size_t len) { - struct kvec *tail; - size_t copy; unsigned int pglen = buf->page_len; - unsigned int tailbuf_len; unsigned int result; - result = 0; - tail = buf->tail; if (len > buf->page_len) len = buf-> page_len; - tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len; - /* Shift the tail first */ - if (tailbuf_len != 0) { - unsigned int free_space = tailbuf_len - tail->iov_len; - - if (len < free_space) - free_space = len; - tail->iov_len += free_space; - - copy = len; - if (tail->iov_len > len) { - char *p = (char *)tail->iov_base + len; - memmove(p, tail->iov_base, tail->iov_len - len); - result += tail->iov_len - len; - } else - copy = tail->iov_len; - /* Copy from the inlined pages into the tail */ - _copy_from_pages((char *)tail->iov_base, - buf->pages, buf->page_base + pglen - len, - copy); - result += copy; - } + result = _shift_data_right_tail(buf, pglen - len, len); buf->page_len -= len; buf->buflen -= len; /* Have we truncated the message? */ From patchwork Mon Sep 28 17:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D151A6CA for ; Mon, 28 Sep 2020 17:09:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B15D52076A for ; Mon, 28 Sep 2020 17:09:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MhyUYvOO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbgI1RJa (ORCPT ); Mon, 28 Sep 2020 13:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgI1RJ3 (ORCPT ); Mon, 28 Sep 2020 13:09:29 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4347C061755 for ; Mon, 28 Sep 2020 10:09:29 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id cv8so806676qvb.12 for ; Mon, 28 Sep 2020 10:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q1kCKc3IoQZq6eAPMW1QAyP6Judd54FV+ny15Qj8+pI=; b=MhyUYvOOShYk+ElnJbooF3oon3yVMzPKIUDYYYHeFCTXgBQq8aD+o1oSuZ68GFEmmA OYWzU0XZd/DR7eU855S2ekx6GWPT1LLAnyCwnfLuUIRp8OvHy+/hmLA2ugj3oYmAcKaK y+IcwR3zwlhT74N7Aov8J4KIbzB+oJFh7H7qvquT3eFgo7caWRdexRxQiQFUZXiSeKkd SIiF9obI3nnsxp2XNf9+by8SqdOsRA4jRVVKx6n88Nm7spjD/PiSeCOSqyrXJdgv+JJM 049hJOEY3rquLT9CHL0fIrqC7VjdA/ub0oehQmeow8EO/FKU9dAFthKRpH/RNOl94oaS QZ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=q1kCKc3IoQZq6eAPMW1QAyP6Judd54FV+ny15Qj8+pI=; b=jHm+yP+V/IL14iTFuR6NuCcNmiE456ZceZA3IVWwO92hpa7ABb5UgmZxNmk0da/bkq 613WzUL6yVUHgEYqU0KTc7vKIJu1rk+Z+jRZzvJEfOzI+q6MkdSb7j3FsElF8XPgIsRl obl7OtwA0veP0a1lkz3CF+bnWZbdqb4fpJMVvvKCH4WK/iUPO10KFJs5JMuPSidbmNDg 8IbzMuQxmyWc1walaXy9lmWdiaG3fE0u56YaxDt1X6O2RF25AywSFVhHg+3nIzDXP+11 cUkRM2hp7X2s76XT219kpGLEvqWIWdpBRoPnmvfYFsftTxbt7wuZFvZQ9zxepoqEoGjI bJwA== X-Gm-Message-State: AOAM533f0CUS4yYhknez02g4UZ2NnQfSidDCmaAOzSXtV9Oj2MAZsoWG VXYxmBqFDKwOLhOG5EAcKA8zaPFBWeU= X-Google-Smtp-Source: ABdhPJx1bUnZW5F3ZYkC4kA4RH36u8yb8ClHp0+yYY9P/JLlDRg1+BQE7kueq/jLkSuAv3MM/2UGdA== X-Received: by 2002:a0c:b31c:: with SMTP id s28mr419064qve.17.1601312968682; Mon, 28 Sep 2020 10:09:28 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:28 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 07/10] SUNRPC: Add the ability to expand holes in data pages Date: Mon, 28 Sep 2020 13:09:16 -0400 Message-Id: <20200928170919.707641-8-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker This patch adds the ability to "read a hole" into a set of XDR data pages by taking the following steps: 1) Shift all data after the current xdr->p to the right, possibly into the tail, 2) Zero the specified range, and 3) Update xdr->p to point beyond the hole. Signed-off-by: Anna Schumaker --- include/linux/sunrpc/xdr.h | 1 + net/sunrpc/xdr.c | 73 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 026edbd041d5..36a81c29542e 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -252,6 +252,7 @@ extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len); extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data); +extern uint64_t xdr_expand_hole(struct xdr_stream *, uint64_t, uint64_t); /** * xdr_stream_remaining - Return the number of bytes remaining in the stream diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index d8c9555c6f2b..24baf052e6e6 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -390,6 +390,42 @@ _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len) } EXPORT_SYMBOL_GPL(_copy_from_pages); +/** + * _zero_pages + * @pages: array of pages + * @pgbase: beginning page vector address + * @len: length + */ +static void +_zero_pages(struct page **pages, size_t pgbase, size_t len) +{ + struct page **page; + char *vpage; + size_t zero; + + page = pages + (pgbase >> PAGE_SHIFT); + pgbase &= ~PAGE_MASK; + + do { + zero = PAGE_SIZE - pgbase; + if (zero > len) + zero = len; + + vpage = kmap_atomic(*page); + memset(vpage + pgbase, 0, zero); + kunmap_atomic(vpage); + + pgbase += zero; + if (pgbase == PAGE_SIZE) { + flush_dcache_page(*page); + pgbase = 0; + page++; + } + + } while ((len -= zero) != 0); + flush_dcache_page(*page); +} + /** * xdr_shrink_bufhead * @buf: xdr_buf @@ -1141,6 +1177,43 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) } EXPORT_SYMBOL_GPL(xdr_read_pages); +uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t length) +{ + struct xdr_buf *buf = xdr->buf; + unsigned int bytes; + unsigned int from; + unsigned int truncated = 0; + + if ((offset + length) < offset || + (offset + length) > buf->page_len) + length = buf->page_len - offset; + + xdr_realign_pages(xdr); + from = xdr_page_pos(xdr); + bytes = xdr->nwords << 2; + + if (offset + length + bytes > buf->page_len) { + unsigned int shift = (offset + length + bytes) - buf->page_len; + unsigned int res = _shift_data_right_tail(buf, from + bytes - shift, shift); + truncated = shift - res; + xdr->nwords -= XDR_QUADLEN(truncated); + bytes -= shift; + } + + /* Now move the page data over and zero pages */ + if (bytes > 0) + _shift_data_right_pages(buf->pages, + buf->page_base + offset + length, + buf->page_base + from, + bytes); + _zero_pages(buf->pages, buf->page_base + offset, length); + + buf->len += length - (from - offset) - truncated; + xdr_set_page(xdr, offset + length, PAGE_SIZE); + return length; +} +EXPORT_SYMBOL_GPL(xdr_expand_hole); + /** * xdr_enter_page - decode data from the XDR page * @xdr: pointer to xdr_stream struct From patchwork Mon Sep 28 17:09:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2EB9618 for ; Mon, 28 Sep 2020 17:09:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C63F52076A for ; Mon, 28 Sep 2020 17:09:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gigoVyK4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726596AbgI1RJb (ORCPT ); Mon, 28 Sep 2020 13:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgI1RJa (ORCPT ); Mon, 28 Sep 2020 13:09:30 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A571CC061755 for ; Mon, 28 Sep 2020 10:09:30 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id w12so1636671qki.6 for ; Mon, 28 Sep 2020 10:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wp5SKBozu7cWhnGG7XLzLGXTHYmhOkgCPiKlw5Gsgd0=; b=gigoVyK4rNgYaZmVJOlhm3zucWr75KVmGFHuE0PQqYGFCv6ycvKYTs4VleDd8pznkE x/LKDhyokdezCz1nF0HJhAowi3Rp7G1vhR2LO9jR2kKzW7HQOlYrJwctmafwyrP5DoyT McyhYR8Qx0sC37JR5cMveKPk1NGkaQ9owEon9EOlOy1lrzLfZt9X7bZ+28GUrEofx0bq ljaIMPP26JCEwN8kQCSBZf7M/hJeBbPXCjU0KJXoBV/ZOpLlehMpSbQksQxFfShSMPoG pK7MYRrfx+l3QzkpncoHHoi/GzLapiiT7AW+z1eoPjoFXfYD1c86rKaW/GDkp1uVRpSe A51Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=wp5SKBozu7cWhnGG7XLzLGXTHYmhOkgCPiKlw5Gsgd0=; b=BKqxeJK4wqYDqDDonHXVrWBjOrPCEyG8B2SffmLmzW+4wfF4I3RHWLAVgv9tEhoGJQ KMOPrfDbYtTRULtn/zZU3TwRhGgXmsXBWYB1p0dNNd4xp83cXoN4l9N3DNY4ALmCBr5h lswvkC5Yk15hRrYLsk8e7z5a6Rg40tsEW0/mJ+rbpRSJHFvwOarreTbCK19NEeixVd74 23rJzvmTF2tiT0pazCPOybuuP5kuwqG+uYr/3D9AEwDMbol4m3YiPpE6HTtmhk46s3Sa D+XOuPP0HTVo5xxWUtEpCIv/3T62OfHB3gWtkAMnwdVKxtTuUbj6+PhhgpzcKTYUSL9j 5pRg== X-Gm-Message-State: AOAM530lRMfJC+CDj4smteF/FOojHI+f/YnRaHaFi9Zq2bAw5xIImTCf XAIN6q2Fw1OptbZd/YQ0V4OLQLSN9Oc= X-Google-Smtp-Source: ABdhPJygd+whpcIcGYTnIukgELTnJM3++lLJCBkUMxAmtw+uyLbM862scfPyP7iZKWIGmo0yGMPDuQ== X-Received: by 2002:a37:b55:: with SMTP id 82mr482747qkl.40.1601312969639; Mon, 28 Sep 2020 10:09:29 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:29 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 08/10] NFS: Add READ_PLUS hole segment decoding Date: Mon, 28 Sep 2020 13:09:17 -0400 Message-Id: <20200928170919.707641-9-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker We keep things simple for now by only decoding a single hole or data segment returned by the server, even if they returned more to us. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 930b4ca212c1..9720fedd2e57 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -53,7 +53,7 @@ #define decode_read_plus_maxsz (op_decode_hdr_maxsz + \ 1 /* rpr_eof */ + \ 1 /* rpr_contents count */ + \ - NFS42_READ_PLUS_SEGMENT_SIZE) + 2 * NFS42_READ_PLUS_SEGMENT_SIZE) #define encode_seek_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + \ 2 /* offset */ + \ @@ -1045,6 +1045,28 @@ static int decode_read_plus_data(struct xdr_stream *xdr, struct nfs_pgio_res *re return 0; } +static int decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *res, + uint32_t *eof) +{ + uint64_t offset, length, recvd; + __be32 *p; + + p = xdr_inline_decode(xdr, 8 + 8); + if (unlikely(!p)) + return -EIO; + + p = xdr_decode_hyper(p, &offset); + p = xdr_decode_hyper(p, &length); + recvd = xdr_expand_hole(xdr, 0, length); + res->count += recvd; + + if (recvd < length) { + *eof = 0; + return 1; + } + return 0; +} + static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) { uint32_t eof, segments, type; @@ -1071,6 +1093,8 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) type = be32_to_cpup(p++); if (type == NFS4_CONTENT_DATA) status = decode_read_plus_data(xdr, res, &eof); + else if (type == NFS4_CONTENT_HOLE) + status = decode_read_plus_hole(xdr, res, &eof); else return -EINVAL; From patchwork Mon Sep 28 17:09:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0D3A618 for ; Mon, 28 Sep 2020 17:09:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB6FC20757 for ; Mon, 28 Sep 2020 17:09:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B20FmcNw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgI1RJc (ORCPT ); Mon, 28 Sep 2020 13:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgI1RJb (ORCPT ); Mon, 28 Sep 2020 13:09:31 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A862DC061755 for ; Mon, 28 Sep 2020 10:09:31 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id c18so1331182qtw.5 for ; Mon, 28 Sep 2020 10:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2rFFPC6YSbh+Yg76JGYrEMjlWJn6VCP0QhRCqwz1dRg=; b=B20FmcNwekmUnVJ5FTv7xvaUzDr+yOI5ILfuFpLG3hf6TUS+qGbAukejIqk1pOdrC5 fbmIIPTGeXJjUOzZ20fOgQZbB9v+ekZ/Zb2ZXLnm8dd0ammJsZ00C/wVmvKHsMntSnmM QdK0+diPznke7dwQdeGpEmvcxLMkp+fqQYGGAnizk6cqHn/X7Lh476qThATvTzg8/t5e bpivH5y7MiV6S5OAHemMbev2MzWnWQZSvMB9YXRR6CO1oK+geKmvqQjF4D0zQhkU2J/b Kn3AH3HQbbi9AQtCRRU7qhwM2gOG2M2LOKFK1Viqk1+UN7wuZfSx4sUSxwKVMp+owNyZ Akow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2rFFPC6YSbh+Yg76JGYrEMjlWJn6VCP0QhRCqwz1dRg=; b=JmChj/D1AetRek+l8+odlKnc6ucYuWcKd8+Sgk8ASADsChXPgNQvsqKToDNh/8YyU1 niEAirmBVXLdSETwKCGAVBiAeFJCi19NDahfnoZbixcyF8fvmSrPMkreEJMhydKhc7w+ C6lRn5wgSf31nMFEn4PrmHSaOUXBVqiBn8+qvWL245Wm26WpYBpfJHycP5E/xFrf4nGz HDbDoCxubac9NAAaR4yhDaqqX9R+0v8ys4cRjnynsaYs9/er2wroL7FiFQhfZQS/SJE/ 1+yENTq6ja0Qeof9RuLrfSPV9CJyTbZJvaVj9jkvt8xuoiZxC7jZn+oMFrVLQJ7sbxWh eMFA== X-Gm-Message-State: AOAM5338gaHQ2mXaDj1TRWXiu2/Rh3voHi2g5zEWjor4PtVkJCYX2TGk oUZrLn6lLhgvquCtBsUmACUVWcz/Xyo= X-Google-Smtp-Source: ABdhPJxPToJMwpGXwgZdM+tip84FBBv+Wi43Jx759wyuv4UFBd4Wq7OuaD1rhxTyeDgrJMSsOS2zMw== X-Received: by 2002:ac8:22f6:: with SMTP id g51mr2586635qta.282.1601312970570; Mon, 28 Sep 2020 10:09:30 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:30 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 09/10] SUNRPC: Add an xdr_align_data() function Date: Mon, 28 Sep 2020 13:09:18 -0400 Message-Id: <20200928170919.707641-10-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker For now, this function simply aligns the data at the beginning of the pages. This can eventually be expanded to shift data to the correct offsets when we're ready. Signed-off-by: Anna Schumaker --- include/linux/sunrpc/xdr.h | 1 + net/sunrpc/xdr.c | 121 +++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 36a81c29542e..9548d075e06d 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -252,6 +252,7 @@ extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len); extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data); +extern uint64_t xdr_align_data(struct xdr_stream *, uint64_t, uint32_t); extern uint64_t xdr_expand_hole(struct xdr_stream *, uint64_t, uint64_t); /** diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 24baf052e6e6..e799cbfe6b5a 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -19,6 +19,9 @@ #include #include +static void _copy_to_pages(struct page **, size_t, const char *, size_t); + + /* * XDR functions for basic NFS types */ @@ -201,6 +204,88 @@ EXPORT_SYMBOL_GPL(xdr_inline_pages); * Helper routines for doing 'memmove' like operations on a struct xdr_buf */ +/** + * _shift_data_left_pages + * @pages: vector of pages containing both the source and dest memory area. + * @pgto_base: page vector address of destination + * @pgfrom_base: page vector address of source + * @len: number of bytes to copy + * + * Note: the addresses pgto_base and pgfrom_base are both calculated in + * the same way: + * if a memory area starts at byte 'base' in page 'pages[i]', + * then its address is given as (i << PAGE_CACHE_SHIFT) + base + * Alse note: pgto_base must be < pgfrom_base, but the memory areas + * they point to may overlap. + */ +static void +_shift_data_left_pages(struct page **pages, size_t pgto_base, + size_t pgfrom_base, size_t len) +{ + struct page **pgfrom, **pgto; + char *vfrom, *vto; + size_t copy; + + BUG_ON(pgfrom_base <= pgto_base); + + pgto = pages + (pgto_base >> PAGE_SHIFT); + pgfrom = pages + (pgfrom_base >> PAGE_SHIFT); + + pgto_base &= ~PAGE_MASK; + pgfrom_base &= ~PAGE_MASK; + + do { + if (pgto_base >= PAGE_SIZE) { + pgto_base = 0; + pgto++; + } + if (pgfrom_base >= PAGE_SIZE){ + pgfrom_base = 0; + pgfrom++; + } + + copy = len; + if (copy > (PAGE_SIZE - pgto_base)) + copy = PAGE_SIZE - pgto_base; + if (copy > (PAGE_SIZE - pgfrom_base)) + copy = PAGE_SIZE - pgfrom_base; + + vto = kmap_atomic(*pgto); + if (*pgto != *pgfrom) { + vfrom = kmap_atomic(*pgfrom); + memcpy(vto + pgto_base, vfrom + pgfrom_base, copy); + kunmap_atomic(vfrom); + } else + memmove(vto + pgto_base, vto + pgfrom_base, copy); + flush_dcache_page(*pgto); + kunmap_atomic(vto); + + pgto_base += copy; + pgfrom_base += copy; + + } while ((len -= copy) != 0); +} + +static void +_shift_data_left_tail(struct xdr_buf *buf, unsigned int pgto, size_t len) +{ + struct kvec *tail = buf->tail; + + if (len > tail->iov_len) + len = tail->iov_len; + + _copy_to_pages(buf->pages, + buf->page_base + pgto, + (char *)tail->iov_base, + len); + tail->iov_len -= len; + + if (tail->iov_len > 0) + memmove((char *)tail->iov_base, + tail->iov_base + len, + tail->iov_len); +} + /** * _shift_data_right_pages * @pages: vector of pages containing both the source and dest memory area. @@ -1177,6 +1262,42 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) } EXPORT_SYMBOL_GPL(xdr_read_pages); +uint64_t xdr_align_data(struct xdr_stream *xdr, uint64_t offset, uint32_t length) +{ + struct xdr_buf *buf = xdr->buf; + unsigned int from, bytes; + unsigned int shift = 0; + + if ((offset + length) < offset || + (offset + length) > buf->page_len) + length = buf->page_len - offset; + + xdr_realign_pages(xdr); + from = xdr_page_pos(xdr); + bytes = xdr->nwords << 2; + if (length < bytes) + bytes = length; + + /* Move page data to the left */ + if (from > offset) { + shift = min_t(unsigned int, bytes, buf->page_len - from); + _shift_data_left_pages(buf->pages, + buf->page_base + offset, + buf->page_base + from, + shift); + bytes -= shift; + + /* Move tail data into the pages, if necessary */ + if (bytes > 0) + _shift_data_left_tail(buf, offset + shift, bytes); + } + + xdr->nwords -= XDR_QUADLEN(length); + xdr_set_page(xdr, from + length, PAGE_SIZE); + return length; +} +EXPORT_SYMBOL_GPL(xdr_align_data); + uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t length) { struct xdr_buf *buf = xdr->buf; From patchwork Mon Sep 28 17:09:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 11804307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9895618 for ; Mon, 28 Sep 2020 17:09:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A1EA2076A for ; Mon, 28 Sep 2020 17:09:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bVg/ZV2V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbgI1RJd (ORCPT ); Mon, 28 Sep 2020 13:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgI1RJc (ORCPT ); Mon, 28 Sep 2020 13:09:32 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88447C061755 for ; Mon, 28 Sep 2020 10:09:32 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id c2so1631460qkf.10 for ; Mon, 28 Sep 2020 10:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=McNZrU0EDFV6A3TZqivdfUIZNz6mK+EHHnD6g+nLLJ8=; b=bVg/ZV2VwDmjNQNJvs0UwPKunkLjs4m3sq29Bfea4c4s7+dsh4ee60got0pIgHha4c HYV7drreqsUjq8Sd5+NNt/CwvozbeLTRQJrJXW5kv/pA2xe5kfW6XDt9W8LB08Eqh+RD icTR3e1rM29Z/J83EGN533Hb4U4A0WLJsn9+QfZ/KMDEnHtdZ4JV62OAHdWvpG8AksGW q5DHv9xPSL6hy23WMecULg7X0Hx9W/uqaqiEptAYR4QmGDj364KUhpXvoy2S3A0qrc1Z G09T5O4ehu+ojQWJ9yGBQ11HoaN03kxFNC+NCXu6baRzrmG7BBBY2MJ8dTS9JM3ZInAm mFeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=McNZrU0EDFV6A3TZqivdfUIZNz6mK+EHHnD6g+nLLJ8=; b=TB6x/VvFGSmYTLK+jJ+qtSOPft4yC0Lte0x0z5DAR1mKpG+JZtksx9eDJTTiEBmCR5 xxqMRcYChsqAGCD+RIY6cRDhPhL/syLUG4EXz2VqIUScXVB538sbtoULVMp6kW4hZdIB 6XmGL7WwV1/zleFU8+R5gOljIaHugKhvpSJpXuCksdIw2cyFqU0wk4+tcAhnePFo22/q vk/6Scto6kyf21sEHM/ym/d5UqexddHdjTQ4lPPu4wzLpREGi8selJSk+jcYf4hAVnQ+ Sf7OLXKPiRUgqgd2SdHPErth7Vw2Zkdiup3qDVGXpLD/0kagwb1mFZPmrLH9Am77KTSu Ge5A== X-Gm-Message-State: AOAM533CviSpSfOkTJDz/71bMjSXOw9u4ijT7xZ2I0RVxQJsouZ9C1C7 FeIxi5znsvwrgFZr5yeFdcD98vYCGLY= X-Google-Smtp-Source: ABdhPJw4lYZFEXcZbiuYbIfTqLcQIn4Y3txOjrjjquLvPNtsVx5st05wFXKCK+GBI2vHqjOcFoeNJw== X-Received: by 2002:a37:9d86:: with SMTP id g128mr458526qke.26.1601312971495; Mon, 28 Sep 2020 10:09:31 -0700 (PDT) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id 201sm1556862qkf.103.2020.09.28.10.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 10:09:31 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v6 10/10] NFS: Decode a full READ_PLUS reply Date: Mon, 28 Sep 2020 13:09:19 -0400 Message-Id: <20200928170919.707641-11-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> References: <20200928170919.707641-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Decode multiple hole and data segments sent by the server, placing everything directly where they need to go in the xdr pages. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 9720fedd2e57..0dc31ad2362e 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -1032,7 +1032,7 @@ static int decode_read_plus_data(struct xdr_stream *xdr, struct nfs_pgio_res *re p = xdr_decode_hyper(p, &offset); count = be32_to_cpup(p); - recvd = xdr_read_pages(xdr, count); + recvd = xdr_align_data(xdr, res->count, count); res->count += recvd; if (count > recvd) { @@ -1057,7 +1057,7 @@ static int decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *re p = xdr_decode_hyper(p, &offset); p = xdr_decode_hyper(p, &length); - recvd = xdr_expand_hole(xdr, 0, length); + recvd = xdr_expand_hole(xdr, res->count, length); res->count += recvd; if (recvd < length) { @@ -1070,7 +1070,7 @@ static int decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *re static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) { uint32_t eof, segments, type; - int status; + int status, i; __be32 *p; status = decode_op_hdr(xdr, OP_READ_PLUS); @@ -1086,22 +1086,24 @@ static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res) if (segments == 0) goto out; - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - return -EIO; + for (i = 0; i < segments; i++) { + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; - type = be32_to_cpup(p++); - if (type == NFS4_CONTENT_DATA) - status = decode_read_plus_data(xdr, res, &eof); - else if (type == NFS4_CONTENT_HOLE) - status = decode_read_plus_hole(xdr, res, &eof); - else - return -EINVAL; + type = be32_to_cpup(p++); + if (type == NFS4_CONTENT_DATA) + status = decode_read_plus_data(xdr, res, &eof); + else if (type == NFS4_CONTENT_HOLE) + status = decode_read_plus_hole(xdr, res, &eof); + else + return -EINVAL; - if (status) - return status; - if (segments > 1) - eof = 0; + if (status < 0) + return status; + if (status > 0) + break; + } out: res->eof = eof;