X-Received: by 2002:a17:902:ea81:b0:14f:a4ce:ef79 with SMTP id x1-20020a170902ea8100b0014fa4ceef79mr2216147plb.136.1645661349137; Wed, 23 Feb 2022 16:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645661349; cv=none; d=google.com; s=arc-20160816; b=gIExkB1uvSTxJ+s38EWf+nO4WRjPA990skg1/2qyRfQBl+nKuY8Tqn0mYLAum6KnY+ WQ+rPjSjhGYJH8TdU+khdNd9CtMIxobNZwigOPwJRsQI2XFgZh47Cp9BiHqBW3us54vO SBz7av7gSt70+HWoPCvbSXyqDjps87/MuqQMQT8AU+ubLOUKxI2LoByuhrdeUgGpvGbV NyVLvEZGjvScoGISf5Z3FJ3rRGmGXkWLFYqqkNYZUDUp44zkfee9pNtTwWDZBQA0apMU XmEEo5/SFKqFDOZ54x8rapoBoiV6MMqFdTFFpisKC4aJMe655L7UTMP8mPs/oZqgMVbU LmGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XbUtvji9wpxfEo7Af7ZvbvV/43NRQEPiiuF6DIU+k4Y=; b=fPlt6AQJpnX+HG6lzT+lK/cUrtuI/VkZf/jcPssMtTGqqRnxCG7p3r9/HYx4oEXe03 t1oR+wkWx8pavMsmQuv8dd9DCpKpuSoC4pae2zygH5Pi+WCRYeCk5TQbwvh9AJwus903 3HJy6CBCZbnMTHnP29wAMX1HBPqLhzzIME+rj7YWQ4f3PRwiXeHaylJaR2sy8uPXyDqx hVpnzwGjsi5ljQkx9B4CkFEhdRNNy0Qv/avADVjQ48dSgbZecic3s6HYl1N+kup+wvbw KY8E42JHlOw9jaAEqq/XeWIjy8BtdyCiZp9Tj6cTGdePdMKOVo2dm3id15Sl/Qfh+aLI PE4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B8TeJvTS; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16si1109647plg.621.2022.02.23.16.08.46; Wed, 23 Feb 2022 16:09:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B8TeJvTS; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242419AbiBWVUG (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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); -- 2.35.1