Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1172027pxb; Tue, 8 Feb 2022 10:49:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVHDBlK77udArxUSLaKtgxsuQ5r6tkZPEoC7k78zsRR3sQFS4iiCujuG/8JS3hiiENMMov X-Received: by 2002:a17:907:3f19:: with SMTP id hq25mr4659884ejc.568.1644346189547; Tue, 08 Feb 2022 10:49:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644346189; cv=none; d=google.com; s=arc-20160816; b=VbC+8QZP69ItXxCylU1N5E0YIXhfZMGL3VOnwxUNjjaBbIPVZDD8Ges7l+gK6FENyC zTlTnwwCFSgHegi4D6lZHpjtGdW/PkhHrRcwU7Fx8PFyJkmQHh0Dn0jjIaF2KvKszAVN D9qL6UVh1Kz6TLaX7aU2xyC5GouAxOC9HTU5JkW1t5IWQFEjTKQDzTTDF+whyVLPIixH n4Ac8AMECWwZQcpSA50qxcyQUlJFmh1Xk6txEThJ80baZQ1y52nZr9A7MpC2JNcipFaa taxNp5dTaYzoetopCD4mWnftTOf2xSC4en6bj5OL5Iakt+ZnjXW37LI4paTMZIhje/LB v2pA== 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=AoIjNa1v1IlXDVM0GASCotnYgkWwKxYPyyPiax+pbG4=; b=E6BpgRyq0FkrqmW0Y9u3zFrqlSOS6fvN1YAicCPHCepgFZbxvcirX6IqDLR1GydTOe mRxC3E90P/9u5k0KuClS+4sH3KCTMd/V5o4Z60wpUtcF4pT/xmd/bUGT0Iua92qdTepL 11G8oToi8++rnxqg7edWQYamGn2I6r5NA2sgKxLZeUpoaSIqOPit2q9+lpFkUWETYujo 6CuwFG5iCKFk10Icn5YiKJuLsDV8buQPXyMYR1u2az53ip5f4je6BFX18VyQQmER4Rnb TtwKCyGZypCJ1cAZbDPtumihd39YL/n2JXCRdP4cOfjWhTEMYvmfvz7WO8Pf9favvrAs Pzrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N2BKNwfC; 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 w15si4156407edt.495.2022.02.08.10.49.25; Tue, 08 Feb 2022 10:49:49 -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=N2BKNwfC; 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 S239071AbiBGVw0 (ORCPT + 99 others); Mon, 7 Feb 2022 16:52:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243124AbiBGVwW (ORCPT ); Mon, 7 Feb 2022 16:52:22 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EF3C0612A4 for ; Mon, 7 Feb 2022 13:52:21 -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 sin.source.kernel.org (Postfix) with ESMTPS id DE5A5CE12F4 for ; Mon, 7 Feb 2022 21:52:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C55C340EF for ; Mon, 7 Feb 2022 21:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644270738; bh=mDJ7+c9NiDpAXTUCW6B1Fr5ZbiEdZ3/+U/lP202Mz5o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N2BKNwfCcMlBdYV+kfHHBGasi5GT0WVwyQ9GXCCOHmtdZTDMMKReoZAofSZOkyPXe a3gGdZb0LHnvwGa4ftXxe1NHStFJzUzi6Nch/aPG2B02rGaeoyDHTHUnqGcZGzmd9E XK3ni5S0fav4W/Dqcfc5NkNDwHVUaepRT1Y9ySvtYH3dMCahy9UwCIyJsV92thwcWz BIXIE1w4O564bLPfWBAu/3qz2lTWSbxlekrnpfu4ywvxXbvs5UT664NhyTwOFDypl6 /3ZseNb86222XUMsR3SdwRWcUvEXLgI37NB1qwdNXqL00pv3G3dN88F9JdpKdAG6n/ tAwQkchn1Mlaw== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] NFS: Simplify nfs_readdir_xdr_to_array() Date: Mon, 7 Feb 2022 16:46:10 -0500 Message-Id: <20220207214610.803566-3-trondmy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220207214610.803566-2-trondmy@kernel.org> References: <20220207214610.803566-1-trondmy@kernel.org> <20220207214610.803566-2-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 | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index c8b62c231080..33eb3a8f0c71 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -868,6 +868,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); @@ -885,27 +886,19 @@ 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); - } while (!status && nfs_readdir_page_needs_filling(page) && - page_mapping(page)); + else + nfs_readdir_page_set_eof(page); +free_pages: nfs_readdir_free_pages(pages, array_size); out: nfs_free_fattr(entry->fattr); -- 2.34.1