From patchwork Wed Jul 22 13:03:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Gr=C3=BCnbacher?= X-Patchwork-Id: 6842891 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4C08EC05AC for ; Wed, 22 Jul 2015 13:08:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 86799206B6 for ; Wed, 22 Jul 2015 13:08:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA290206D0 for ; Wed, 22 Jul 2015 13:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965087AbbGVNIb (ORCPT ); Wed, 22 Jul 2015 09:08:31 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:32936 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757024AbbGVNEt (ORCPT ); Wed, 22 Jul 2015 09:04:49 -0400 Received: by wicmv11 with SMTP id mv11so80748829wic.0; Wed, 22 Jul 2015 06:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=77FsuwTUBrJ5v8VfpePks27+hn5Rk25J6Dvlxwirybw=; b=05LUdPCovlFiMkh30FYw9QGqZpHZngYWQ4+b05n2oZIGbmIHiBrXY9LR+jRKxqssWR tTxFUqMkQBccBu2n43Yn6sd8rUSbBAZkaJHGyRxgPzlv2O8V0Qqisei0S7630RTELbUE u/2pmmdoHdD6+/haXR7vfus0K3CW933CyQGcgIzIZV0d97tsBQiKes27kTh/rpxiYKI1 pX8KqKbQY0SPw14MZL+6NhoLpBbAybP/OKzocqu4XCJsf7UPUcjht6/qg9cITmo4GRk1 RpPCeIxTTRr5j7efJSAQGe8L42p/vCS2vxO8I7bA1gmPjrhSIzkjJYDtxsnGvW49Vaxr TXiA== X-Received: by 10.180.77.107 with SMTP id r11mr6449320wiw.74.1437570286791; Wed, 22 Jul 2015 06:04:46 -0700 (PDT) Received: from schleppi.home.com ([149.14.88.26]) by smtp.gmail.com with ESMTPSA id u7sm21992628wif.3.2015.07.22.06.04.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 06:04:46 -0700 (PDT) From: Andreas Gruenbacher To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-api@vger.kernel.org, samba-technical@lists.samba.org, linux-security-module@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH v5 34/39] sunrpc: Allow to demand-allocate pages to encode into Date: Wed, 22 Jul 2015 15:03:24 +0200 Message-Id: <1437570209-29832-35-git-send-email-andreas.gruenbacher@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437570209-29832-1-git-send-email-andreas.gruenbacher@gmail.com> References: <1437570209-29832-1-git-send-email-andreas.gruenbacher@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andreas Gruenbacher When encoding large, variable-length objects such as acls into xdr_bufs, it is easier to allocate buffer pages on demand rather than precomputing the required buffer size. Signed-off-by: Andreas Gruenbacher --- net/sunrpc/xdr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 4439ac4..e6a1744 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -537,6 +537,14 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, */ xdr->scratch.iov_base = xdr->p; xdr->scratch.iov_len = frag1bytes; + + if (!*xdr->page_ptr) { + struct page *page = alloc_page(GFP_NOFS); + if (!page) + return NULL; + *xdr->page_ptr = page; + } + p = page_address(*xdr->page_ptr); /* * Note this is where the next encode will start after we've