From patchwork Tue Aug 4 11:53:33 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: 6937041 Return-Path: X-Original-To: patchwork-linux-nfs@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 99482C05AD for ; Tue, 4 Aug 2015 11:58:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C951020452 for ; Tue, 4 Aug 2015 11:58:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D74FF20495 for ; Tue, 4 Aug 2015 11:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933576AbbHDL6P (ORCPT ); Tue, 4 Aug 2015 07:58:15 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:38750 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933796AbbHDLzr (ORCPT ); Tue, 4 Aug 2015 07:55:47 -0400 Received: by wibxm9 with SMTP id xm9so20365287wib.1; Tue, 04 Aug 2015 04:55:45 -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=GInfVJhNpG0T8fK9RVeknDxOQDimLy4ExFRrEFtOSLY=; b=cRYstvvSsH+/IpwbaSMak6udI2Ns0bKEJfAwQ6kIbZEomVhAaeHV7b2ojoBTpY/+cF p0GByU3kIMjNXo26cQ52JmoQkxhJ/zNbR2R1KQ4cHkAERfKuCLRe04KMPWskBfSijUbN NRviL3iPaL66W8M5BQYmY6IAd+557TnEUfdjALgd9nUnYzQGEp1SsYEXUPdRSHzaUWAP igHlpN1kC0Zx7KQVTxxGGSg4RfR5X3Ur7B2xOH5WTXj3A1XucdumlAkdZDXgsiwOQr35 22W+TzOPww9x5bo+jF6jNuIPJ7VJ0/A7AHzWOkTd3VNSY9p2LNyMSsPQz6ZltmxQEyEV 3wDQ== X-Received: by 10.194.81.67 with SMTP id y3mr7076585wjx.7.1438689345626; Tue, 04 Aug 2015 04:55:45 -0700 (PDT) Received: from schleppi.home.com (p54980F84.dip0.t-ipconnect.de. [84.152.15.132]) by smtp.gmail.com with ESMTPSA id u7sm2018458wif.3.2015.08.04.04.55.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 04:55:44 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-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, linux-cifs@vger.kernel.org, linux-security-module@vger.kernel.org, Andreas Gruenbacher Subject: [RFC v6 35/40] sunrpc: Allow to demand-allocate pages to encode into Date: Tue, 4 Aug 2015 13:53:33 +0200 Message-Id: <1438689218-6921-36-git-send-email-agruenba@redhat.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438689218-6921-1-git-send-email-agruenba@redhat.com> References: <1438689218-6921-1-git-send-email-agruenba@redhat.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SUSPICIOUS_RECIPS, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 4439ac4..63c1c36 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -537,6 +537,15 @@ 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