Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2219350pxp; Sun, 13 Mar 2022 12:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbCQRlkrssFBWD5JIUIRigfsCNadRXTv27MrTdBf02EGzXAIRwEuRZ9emzp7rMtUeEjk4G X-Received: by 2002:a17:906:7944:b0:6da:b834:2f3e with SMTP id l4-20020a170906794400b006dab8342f3emr16329045ejo.353.1647198385405; Sun, 13 Mar 2022 12:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647198385; cv=none; d=google.com; s=arc-20160816; b=FKB3OB8v9BAwCFYdbZBCku4vWEA2r3VS4cJq/oWXEW8dswOEuOwRgeSgTpOkp6XZAW yn6atI4Od7rLXLrzMDDEgWfJOm/hGCDEMiZhsE5dMHC6Pg3Hy23IQUmo0nDVxQLNDV69 2rvcAQVDOiQQtak4oITusqVHL+3J7S4POA2LnnEnI6+kAYT/W4vVxROduv6hHx6cz4zp OPob4BON0FsvPWNxprx3QL745TUjj4NRzjoCVK2cJVHekcq6ZFFFdnv+7LBXV7ARcLIK QYvaoqAUC1075Hq7SR99nnEQiIRCWQZIRm7uU3jcVOJRdB/Hs3/MJlNEaa3KyowFtE+l itiw== 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=Lpaz427XbFkNrlK3B60e3DeoMXsKSmScqXkxVWOLnvY=; b=n/XsSE5liIbB/N6ANgtttV3q11YE5GligLIINYv1pUJ1qA8qGGJRqkhXGErzzS5CKe /r1GWHqKRfap0RAB5jFWb9IfZ6xyUD8KiVDd6fy+VQwqCqvOcIUSLLh3dHtF8UCyI5gA NXHf5wInsstSPPGezhrQZiUrAzbiq+/yjePShcwwPjtYnFaTclQlQbdMMXjFKAOQLpdw Bin5daH3Ov6sI1/CLuiOmGfFvxdkSAEhTGcpa8YoaXssDCWG3DSeZSyMqGD5o4ZJatRu xRqBJvx9Mzj4EvlRehmViy8s/xfLEHt4n1T6cl9p7GUgmgjA3BByDFEaRJGfopdw1ZZX VPmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SWzuSGBA; 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 x10-20020a1709060eea00b006b51c87e99fsi7662295eji.812.2022.03.13.12.06.02; Sun, 13 Mar 2022 12:06:25 -0700 (PDT) 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=SWzuSGBA; 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 S235089AbiCMRNV (ORCPT + 99 others); Sun, 13 Mar 2022 13:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235113AbiCMRNT (ORCPT ); Sun, 13 Mar 2022 13:13:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A39139CFE for ; Sun, 13 Mar 2022 10:12:11 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id BB58FB80CAD for ; Sun, 13 Mar 2022 17:12:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B671C340E8 for ; Sun, 13 Mar 2022 17:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647191528; bh=nXGvvAaZjXNCImpZyKPlB83LM1gB9xUedQJdbZ0r3WE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SWzuSGBASmChi4lR9zdhwhD9hWO7MGt5mxBbuYV6amxChxyYCFXyo4QkSE+jkO/v9 gHlA7z6J+y0tC/TfD3YyZDZ43DsnvF60mnKA46pqKA6rHpsAk2Pu861uKS0xPihm6d Jpd3tyS1IlAA2OIG4bDiloVeEbyAn5jrMxhqx0qqP+hfrBx/sKMNRxvaUuFGtN35cZ mqW2yqXHfhm0rg0WXk8fpkNnmKgonBzRP2Ls0/3zR+f6lZYpqe2HtOJ/llN+bfdv1A sJDjNMGplH4yqUU9c//Fe2EeOSP6bdik/0H/mt+FXQ1ZzqckqK8nqDDYIMFXeJexQg sg8Eo/SwPK3zg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v10 12/26] NFS: Simplify nfs_readdir_xdr_to_array() Date: Sun, 13 Mar 2022 13:05:43 -0400 Message-Id: <20220313170557.5940-13-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220313170557.5940-12-trondmy@kernel.org> References: <20220313170557.5940-1-trondmy@kernel.org> <20220313170557.5940-2-trondmy@kernel.org> <20220313170557.5940-3-trondmy@kernel.org> <20220313170557.5940-4-trondmy@kernel.org> <20220313170557.5940-5-trondmy@kernel.org> <20220313170557.5940-6-trondmy@kernel.org> <20220313170557.5940-7-trondmy@kernel.org> <20220313170557.5940-8-trondmy@kernel.org> <20220313170557.5940-9-trondmy@kernel.org> <20220313170557.5940-10-trondmy@kernel.org> <20220313170557.5940-11-trondmy@kernel.org> <20220313170557.5940-12-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 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 9998d7d17367..9d086ab4f889 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -889,6 +889,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); @@ -906,28 +907,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