From patchwork Wed Feb 23 21:12:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 12757517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AE50C433F5 for ; Wed, 23 Feb 2022 21:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242419AbiBWVUG (ORCPT ); Wed, 23 Feb 2022 16:20:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242423AbiBWVUE (ORCPT ); Wed, 23 Feb 2022 16:20:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 309EF4ECDA for ; Wed, 23 Feb 2022 13:19:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1267961650 for ; Wed, 23 Feb 2022 21:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A127C340F0 for ; Wed, 23 Feb 2022 21:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645651175; bh=haB0TZhsy/Akzv5gxDiPKiHprJp2VAgbi/1a8/Kry2U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B8TeJvTS2XemG2IiAsvYNkevY17OM+bITf/ENLWpH4VaHELNd+nV5Btzs3KHpLGJT pvB6VbT/9jK/bTILKno//fr86wszbmZNaREKI+BIQ+76Vq6Txb4O7DrWoPEI+T+jZA oibThjyu9ZCUh5QghmNe1dx8bJ64WZ9eeryds/Mo9cC0WGt9jy+898fjZdA5Z9DVHt 9UEsKp+0hn7Ec71CgNHQq60vcpWcOVheIEpVtU5EAekcHrvvFYSDwoZ1VT3C+HA1OR IfiFKhoc768iqeGWibxKoyuqrYXDikEs3MCyXHt0MOQ0qYKpYwtDXb54LDAcgJbrOO hvJHhraQMH+KA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v7 09/21] NFS: Simplify nfs_readdir_xdr_to_array() Date: Wed, 23 Feb 2022 16:12:53 -0500 Message-Id: <20220223211305.296816-10-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220223211305.296816-9-trondmy@kernel.org> References: <20220223211305.296816-1-trondmy@kernel.org> <20220223211305.296816-2-trondmy@kernel.org> <20220223211305.296816-3-trondmy@kernel.org> <20220223211305.296816-4-trondmy@kernel.org> <20220223211305.296816-5-trondmy@kernel.org> <20220223211305.296816-6-trondmy@kernel.org> <20220223211305.296816-7-trondmy@kernel.org> <20220223211305.296816-8-trondmy@kernel.org> <20220223211305.296816-9-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Recent changes to readdir mean that we can cope with partially filled page cache entries, so we no longer need to rely on looping in nfs_readdir_xdr_to_array(). Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 83933b7018ea..9b0f13b52dbf 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -879,6 +879,7 @@ static int nfs_readdir_xdr_to_array(struct nfs_readdir_descriptor *desc, size_t array_size; struct inode *inode = file_inode(desc->file); unsigned int dtsize = desc->dtsize; + unsigned int pglen; int status = -ENOMEM; entry = kzalloc(sizeof(*entry), GFP_KERNEL); @@ -896,28 +897,20 @@ static int nfs_readdir_xdr_to_array(struct nfs_readdir_descriptor *desc, if (!pages) goto out; - do { - unsigned int pglen; - status = nfs_readdir_xdr_filler(desc, verf_arg, entry->cookie, - pages, dtsize, - verf_res); - if (status < 0) - break; - - pglen = status; - if (pglen == 0) { - nfs_readdir_page_set_eof(page); - break; - } - - verf_arg = verf_res; + status = nfs_readdir_xdr_filler(desc, verf_arg, entry->cookie, pages, + dtsize, verf_res); + if (status < 0) + goto free_pages; + pglen = status; + if (pglen != 0) status = nfs_readdir_page_filler(desc, entry, pages, pglen, arrays, narrays); - desc->buffer_fills++; - } while (!status && nfs_readdir_page_needs_filling(page) && - page_mapping(page)); + else + nfs_readdir_page_set_eof(page); + desc->buffer_fills++; +free_pages: nfs_readdir_free_pages(pages, array_size); out: nfs_free_fattr(entry->fattr);