Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp417148pxu; Sun, 22 Nov 2020 13:07:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/C2XkJFbdBnRN0kmRCRZ2Du+Qrljq1RGBt1I7YPWs6nOfQhFXYgSzmOZqxRMToN4c6gUn X-Received: by 2002:a17:906:489a:: with SMTP id v26mr27735520ejq.422.1606079263423; Sun, 22 Nov 2020 13:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606079263; cv=none; d=google.com; s=arc-20160816; b=uCyCR+5B6kHrDEpdM2GzUN1ju1n/ePc2fLHZ8mwTaphhgdZSHAwz9KeI1YSDVZAuqx rfTLIAhG0EtljxkLQEI1q9kEi2nNmnQBuU/Whfn1mBHaSzbAznkuVrSoYGMfa4Hhr8up O8LXmDkwQcNEpx3iPlpu2nCgIjQLrurCNVVlw2prSKdWPS4E89aNfDWe14s6d8+OxAWe adIeG3dpk/DyogQ3Enyz3jQsO+BZ9RFGmKz9QgKMxDlaprHieb19nKZBukaJ4GfnVPG2 Jv9Nu6nKgfyzBlwd7u159Y7iurjeP9UG0O9kEUf3aeXZ4pAT0Y+pjojB7DFfr6KB9ZPW n7Pg== 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:to:from :dkim-signature; bh=3k9qqUzBk3wV8Wl/A13rhWUypLpiTr1i367uzglUSh8=; b=RehKVC5ahOwnNfuLs691/W6N5fCdN1AYlLAXNLIrbPsdKgkgXUvnVhezkXySsk6vHk MFUbkSDIl/o9mihDowFR2UUJmSDKzOU7xSMc7FMFkXKMJWX2suR6ZHHezKnBK7wuTvh5 gDZOnCYAhuqHhTJQDV8xXHW8LgaebJFZOMQQAWWRbzauU+yAWlrcAi6gM4TBt6Oj79k+ tuGMN/xfv0ShNhuIRDdH3/JBh+r06y+GxjshtWvyC/bMunddxTv5aFnO2dEeigCkcf5M 68lOvvRLqsc5cA7JMh4EckJsXnncmWHCZD7sUBpLE/73Jtd4BLdMXrs0vjX97h7L96hj gtPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hFSfur5n; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w8si5543536ejo.321.2020.11.22.13.07.20; Sun, 22 Nov 2020 13:07:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hFSfur5n; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbgKVUwh (ORCPT + 99 others); Sun, 22 Nov 2020 15:52:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:57600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbgKVUwh (ORCPT ); Sun, 22 Nov 2020 15:52:37 -0500 Received: from leira.hammer.space (c-68-36-133-222.hsd1.mi.comcast.net [68.36.133.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D8262078B for ; Sun, 22 Nov 2020 20:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606078356; bh=81c8hXVAexxERZg1aSClqsGHLBDQbE4w7uJ52QJYrmA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hFSfur5nOGjCu23vvjs2LoChnUIw7jYWz1Ox2yNZx3LNJK+DsmQa8S9bAg6CKkhxe 6xBcCCm/YzKVsM4InTGfXBaMHcV4G9Gi6H3O80xUxQ7J2aV6lEhGz4herq0WA1NJq8 MaJosCEa8U0QTbCx2d5bNuda2ux+SY+fS2gpcWNE= From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 6/8] SUNRPC: Fix up xdr_set_page() Date: Sun, 22 Nov 2020 15:52:27 -0500 Message-Id: <20201122205229.3826-7-trondmy@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201122205229.3826-6-trondmy@kernel.org> References: <20201122205229.3826-1-trondmy@kernel.org> <20201122205229.3826-2-trondmy@kernel.org> <20201122205229.3826-3-trondmy@kernel.org> <20201122205229.3826-4-trondmy@kernel.org> <20201122205229.3826-5-trondmy@kernel.org> <20201122205229.3826-6-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust While we always want to align to the next page and/or the beginning of the tail buffer when we call xdr_set_next_page(), the functions xdr_align_data() and xdr_expand_hole() really want to align to the next object in that next page or tail. Signed-off-by: Trond Myklebust --- net/sunrpc/xdr.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 5a450055469f..ddd5cc2281ab 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -1019,8 +1019,10 @@ static unsigned int xdr_set_page_base(struct xdr_stream *xdr, 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, 0, xdr_stream_remaining(xdr)); + if (xdr_set_page_base(xdr, base, len) == 0) { + base -= xdr->buf->page_len; + xdr_set_iov(xdr, xdr->buf->tail, base, len); + } } static void xdr_set_next_page(struct xdr_stream *xdr) @@ -1029,17 +1031,18 @@ 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; - - xdr_set_page(xdr, newbase, PAGE_SIZE); + if (newbase < xdr->buf->page_len) + xdr_set_page_base(xdr, newbase, xdr_stream_remaining(xdr)); + else + xdr_set_iov(xdr, xdr->buf->tail, 0, xdr_stream_remaining(xdr)); } 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) { - xdr_set_page(xdr, 0, PAGE_SIZE); - } + else if (xdr->iov == xdr->buf->head) + xdr_set_page(xdr, 0, xdr_stream_remaining(xdr)); return xdr->p != xdr->end; } @@ -1277,7 +1280,7 @@ uint64_t xdr_align_data(struct xdr_stream *xdr, uint64_t offset, uint32_t length } xdr->nwords -= XDR_QUADLEN(length); - xdr_set_page(xdr, from + length, PAGE_SIZE); + xdr_set_page(xdr, from + length, xdr_stream_remaining(xdr)); return length; } EXPORT_SYMBOL_GPL(xdr_align_data); @@ -1314,7 +1317,7 @@ uint64_t xdr_expand_hole(struct xdr_stream *xdr, uint64_t offset, uint64_t lengt _zero_pages(buf->pages, buf->page_base + offset, length); buf->len += length - (from - offset) - truncated; - xdr_set_page(xdr, offset + length, PAGE_SIZE); + xdr_set_page(xdr, offset + length, xdr_stream_remaining(xdr)); return length; } EXPORT_SYMBOL_GPL(xdr_expand_hole); -- 2.28.0