Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2347237pxm; Sun, 27 Feb 2022 18:58:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJydyWSjcwkB+PuO0gZBXr7uOKke5LArTjhPeUBTrE0oVvq+KXwbIDUCxG+XfQf3WFhOmc2n X-Received: by 2002:aa7:9429:0:b0:4e1:5814:79b3 with SMTP id y9-20020aa79429000000b004e1581479b3mr19110338pfo.82.1646017106092; Sun, 27 Feb 2022 18:58:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646017106; cv=none; d=google.com; s=arc-20160816; b=GSE/9u3kYsDRbG18qXQelRa8egk4KdtsQ5QXBjrBcYu25e3MR+6FYcvWRAzu8vz1MU WtIb5qnAZgzRGB0pvsX1n/kopLhdeb8+2uadKDlyMoTiAvsnwgc6fh9MNetfR2Onh2yk zPjM2RW8VITI8JYrcPStls4upnkYO26soVeILtqETZ0BeK90LF7SyIQT1EzU9ZoCWlTV SbFUV2C1fTIJHOOxQRanAw4fvxJ4VlMq7/OsKju8nSfKX6dUkUYgJ1kar98WcrvlL+kL MoqL3hDBDTE4LwtNW8+4FIKpNn/7iN+9EXBoIGog8BnF/VSYVwYJEd2qCM+WOw8WAA9P 3s2Q== 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=+1mKtbA12d8D9FLhqLjapFfoWq0ganT9bd+XyVXhb0s=; b=p3lCjdyS/5okPBxWuvOLuwQrxOvA5oR4HA1iD+T8oE6lg+8ECGRDowg9bkbwWAaayz 4UqtuVmJLOKNuO3mH4KG0aucwg4vvaWAGL4WoU/qfvdwHEHeeI79Quz9MzqetFLJxbW7 quMIAAKD7CCajuSvn+1O4IHV9WA/SL4+AZEadEqtSF4g9N/rZEDj7ge+nJKdyvfxEtvG ZVmc6iAm+makiKfpS/4r0nBVQ3jlllIXegXOCH9Jyv2NEmOMsTbwG7jF6PIljI9pIllR BKLfhWwdGWh51UE8wsUP/6CWsbeDjiTCUHyVOg80FeTmSVV6a47/0mHdGgP7Sko7W6bx axig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fTBg9BMU; 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 in2-20020a17090b438200b001bc545e019dsi13296848pjb.90.2022.02.27.18.58.09; Sun, 27 Feb 2022 18:58:26 -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=fTBg9BMU; 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 S232183AbiB0XTS (ORCPT + 99 others); Sun, 27 Feb 2022 18:19:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232194AbiB0XTQ (ORCPT ); Sun, 27 Feb 2022 18:19:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57ED32252C for ; Sun, 27 Feb 2022 15:18:39 -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 DA12E611D9 for ; Sun, 27 Feb 2022 23:18:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80936C340F4 for ; Sun, 27 Feb 2022 23:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646003918; bh=hKQUvtnpqFG/afdRJ64KhIRZilINRjMQpyN/U2xkgtU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fTBg9BMUyfUtq2RuzOKRbS7jymKGJTax/Ny5v1c3bMKEspl/eP27GL6gp3SsYKKyq 9/sElAWa+JCfgE7pgsjIx0qz0xajV9H0HNsNp+upcg1fyFnLZoXo4jnEXhbP/RMlF9 GUE45FDu9UWL12qPl9suYo0zd7uOvyPaENztwZ/RVROLPNg2S1MiBS2i2LlZcCg47Y y8BqKdkqvbaozEp2sANgKZfWcaHw3h0mfxneGzcVLLTatREQpt7p592Z6CbKHs4ELE yKj/iO1PmV3mz90BRg/25Juo5hPwRDejPpvndl+h0HvHYoofcBQaxrh9nCwyH1meds nblW3HNhmgDFw== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v9 12/27] NFS: Simplify nfs_readdir_xdr_to_array() Date: Sun, 27 Feb 2022 18:12:12 -0500 Message-Id: <20220227231227.9038-13-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227231227.9038-12-trondmy@kernel.org> References: <20220227231227.9038-1-trondmy@kernel.org> <20220227231227.9038-2-trondmy@kernel.org> <20220227231227.9038-3-trondmy@kernel.org> <20220227231227.9038-4-trondmy@kernel.org> <20220227231227.9038-5-trondmy@kernel.org> <20220227231227.9038-6-trondmy@kernel.org> <20220227231227.9038-7-trondmy@kernel.org> <20220227231227.9038-8-trondmy@kernel.org> <20220227231227.9038-9-trondmy@kernel.org> <20220227231227.9038-10-trondmy@kernel.org> <20220227231227.9038-11-trondmy@kernel.org> <20220227231227.9038-12-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 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 eaf8d5cddb0f..0c190c93901e 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