From patchwork Fri Mar 27 16:50:36 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: 6109721 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 69BE09F2A9 for ; Fri, 27 Mar 2015 16:53:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 884C3203AD for ; Fri, 27 Mar 2015 16:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A99E1203DA for ; Fri, 27 Mar 2015 16:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753007AbbC0QxP (ORCPT ); Fri, 27 Mar 2015 12:53:15 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:36749 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754096AbbC0Qwf (ORCPT ); Fri, 27 Mar 2015 12:52:35 -0400 Received: by wgra20 with SMTP id a20so105291739wgr.3; Fri, 27 Mar 2015 09:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references:in-reply-to :references; bh=ymIClp1gGUjAA5QHJeYY98dTRkcgbMqrbSjHyUkndqk=; b=Iau9PDbH2CHuNEP5RYua8E+VBziO4RSaFsWUAy6X76sU7Dshe4Hq38D1R47vVo89qt mrMH8IUqzgsZAtOecFaD3hpV40lKWfFCzTRw3vef3R6OVt/TyMNxEvV3zZ6YetjOlrC2 yBKH//hW0EvB2eL25puroM9uXxF6gthn/xXP47Hc7qsbjBStrnqBjBTYVkms+jvplcwL mNQR33UvGMq07Rhl4S8oD7iy6tyjZOUbGzhZsQFsuZM5rBkDcyj6YaArt3rTF/axHTdS nIvGXQ6+D9C7z4NhHphNv4QqHGjFlsv2IhZBYI4C30wKD1AVWH3uHKoDALikVibPzK3l t9aA== X-Received: by 10.180.80.101 with SMTP id q5mr52240491wix.83.1427475153340; Fri, 27 Mar 2015 09:52:33 -0700 (PDT) Received: from nuc.home.com (80-110-94-70.cgn.dynamic.surfer.at. [80.110.94.70]) by mx.google.com with ESMTPSA id j7sm3592306wix.4.2015.03.27.09.52.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 09:52:32 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-From: Andreas Gruenbacher To: "J. Bruce Fields" , Trond Myklebust , Anna Schumaker , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [RFC 38/39] rpc: Allow to demand-allocate pages to encode into Date: Fri, 27 Mar 2015 17:50:36 +0100 Message-Id: <73447bd6fc331c911d32f212d85cc65898432ce5.1427471526.git.agruenba@redhat.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 When encoding large, variable-length objects such as acls into xdr_bufs, it is easier to allocate buffer pages on demand rather than computing the required buffer size beforehand. 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..062951b 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_KERNEL); + if (!page) + return ERR_PTR(-ENOMEM); + *xdr->page_ptr = page; + } + p = page_address(*xdr->page_ptr); /* * Note this is where the next encode will start after we've