From patchwork Sun Feb 19 02:07:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Fields X-Patchwork-Id: 9581443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6324E60586 for ; Sun, 19 Feb 2017 02:08:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5524C287A0 for ; Sun, 19 Feb 2017 02:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A0E5287BD; Sun, 19 Feb 2017 02:08:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B2F287B7 for ; Sun, 19 Feb 2017 02:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196AbdBSCIh (ORCPT ); Sat, 18 Feb 2017 21:08:37 -0500 Received: from fieldses.org ([173.255.197.46]:36014 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbdBSCId (ORCPT ); Sat, 18 Feb 2017 21:08:33 -0500 Received: by fieldses.org (Postfix, from userid 2815) id 2A5AA46ED; Sat, 18 Feb 2017 21:07:53 -0500 (EST) From: "J. Bruce Fields" To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Andreas Gruenbacher , Weston Andros Adamson , Weston Andros Adamson , "J. Bruce Fields" Subject: [PATCH 6/6] NFSv4: allow getacl rpc to allocate pages on demand Date: Sat, 18 Feb 2017 21:07:50 -0500 Message-Id: <1487470070-32358-7-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487470070-32358-1-git-send-email-bfields@redhat.com> References: <1487470070-32358-1-git-send-email-bfields@redhat.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Weston Andros Adamson Instead of preallocating pags, allow xdr_partial_copy_from_skb() to allocate whatever pages we need on demand. This is what the NFSv3 ACL code does. Signed-off-by: J. Bruce Fields Reviewed-by: Andreas Gruenbacher Signed-off-by: Weston Andros Adamson --- fs/nfs/nfs4proc.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3e3dbba4aa74..7842c73fddfc 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5068,6 +5068,7 @@ static ssize_t nfs4_do_get_acl(struct inode *inode, void *buf, size_t buflen) struct page *pages[NFS4ACL_MAXPAGES + 1] = {NULL, }; struct nfs_getaclargs args = { .fh = NFS_FH(inode), + /* The xdr layer may allocate pages here. */ .acl_pages = pages, }; struct nfs_getaclres res = { @@ -5079,32 +5080,22 @@ static ssize_t nfs4_do_get_acl(struct inode *inode, void *buf, size_t buflen) .rpc_argp = &args, .rpc_resp = &res, }; - unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE) + 1; - int ret = -ENOMEM, i; - - if (npages > ARRAY_SIZE(pages)) - return -ERANGE; - - for (i = 0; i < npages; i++) { - pages[i] = alloc_page(GFP_KERNEL); - if (!pages[i]) - goto out_free; - } + int ret, i; /* for decoding across pages */ res.acl_scratch = alloc_page(GFP_KERNEL); if (!res.acl_scratch) - goto out_free; + return -ENOMEM; - args.acl_len = npages * PAGE_SIZE; + args.acl_len = ARRAY_SIZE(pages) << PAGE_SHIFT; - dprintk("%s buf %p buflen %zu npages %d args.acl_len %zu\n", - __func__, buf, buflen, npages, args.acl_len); + dprintk("%s buf %p buflen %zu args.acl_len %zu\n", + __func__, buf, buflen, args.acl_len); ret = nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode), &msg, &args.seq_args, &res.seq_res, 0); if (ret == 0) ret = res.acl_len; -out_free: + for (i = 0; i < ARRAY_SIZE(pages) && pages[i]; i++) __free_page(pages[i]); __free_page(res.acl_scratch);