Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:41063 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752678AbbJWSrC (ORCPT ); Fri, 23 Oct 2015 14:47:02 -0400 From: Andreas Gruenbacher To: Alexander Viro , "Theodore Ts'o" , Andreas Dilger , "J. Bruce Fields" , Jeff Layton , Trond Myklebust , Anna Schumaker , Dave Chinner , linux-ext4@vger.kernel.org, xfs@oss.sgi.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-api@vger.kernel.org Cc: Andreas Gruenbacher Subject: [PATCH v12 43/49] sunrpc: Allow to demand-allocate pages to encode into Date: Fri, 23 Oct 2015 20:41:56 +0200 Message-Id: <1445625722-13791-44-git-send-email-agruenba@redhat.com> In-Reply-To: <1445625722-13791-1-git-send-email-agruenba@redhat.com> References: <1445625722-13791-1-git-send-email-agruenba@redhat.com> Sender: linux-nfs-owner@vger.kernel.org List-ID: 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 -- 2.5.0