Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2219238pxp; Sun, 13 Mar 2022 12:06:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgilg9vvvdK3dXj2xVxXuwP5jN/npTX+XGAJk1MubG9K37a4bU1oyi77y46P4mWcLu8jmX X-Received: by 2002:a17:906:2f94:b0:6cf:e4f7:13a with SMTP id w20-20020a1709062f9400b006cfe4f7013amr16206106eji.269.1647198374368; Sun, 13 Mar 2022 12:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647198374; cv=none; d=google.com; s=arc-20160816; b=Qor4L0XOqJ/9l7fbHgQjUWDqDQ6eq8CqNHnFQcRHchHX4QqhwCn9F2fqQUJSHx5o4V vMF0zbSc/TOLkU6zbdgd01qdSRBYbtiUjOe8t8jQEkjOnt9c/HLvdVPwviTOb4oOOOtL 9xp+znlShKlt12zjrRhgSxtzPzl3QCVGspBAy+hF31ZzYNJ8MzpU+ArArOoNQSp4z2wE AL4WDfEM9PzXHERd3KI4+wfxGREWtUoZTy9xN+C0KHSlY+GNk5aBpHMyHbzLTH2HjZnk 61j9UA9LMzxz0b4LVcMHKYKqpF53dePP8rKB5HpBOTy/4D51p+GZAJJ6Xc+2+oXpEl4A qb4g== 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=cZr29JBHyTOIV7zEFHFlbxpn3k8YPwkySx7uQKaZYVk=; b=nZRa77o/Uj8nih1XPO08hCw8jlxEA6ila+gFiZT0w2HhT7TWnMj60HWHQp3vYJsEdw kJnnlmQU/FVllgBzvQ5TfWl3Y94l3hAHMnUaiGXTkp1RqxKITGYx/qJpCdJhXygSZFS7 0cKa7arg1exy4LcIpjarI47JzqicApws7w/9wsnoJ+1zYmbe6a6+6u2Nn2MfyZp9hH0m KJthltLFOT4iNZVj92r7UdmpZcS0se4Nf0q/QCpmLB6383SsWEKGW2yorTETysULeS05 CDF/yd+tBDx/xgoEq0YGj2i75+S5pljmlt/6/MFfoGFcgKG0zcLpMdcfZX/r1pfV0Hmb PS9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SyOk7GOG; 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 hd33-20020a17090796a100b006db2b213b3dsi8971840ejc.723.2022.03.13.12.05.51; Sun, 13 Mar 2022 12:06:14 -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=SyOk7GOG; 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 S235112AbiCMRNU (ORCPT + 99 others); Sun, 13 Mar 2022 13:13:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235089AbiCMRNR (ORCPT ); Sun, 13 Mar 2022 13:13:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC227139CDA for ; Sun, 13 Mar 2022 10:12:09 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 77EE460FDD for ; Sun, 13 Mar 2022 17:12:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0DC5C340F6 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=8lRolItTloqfN5M+Lqc6/wyGKRBsorfh9R80QBz5eTQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SyOk7GOGDynq+pqTVrLDrFp4V6mA2KjNHpKjko6ZMVGFPTDHYcmkgFSVz85yhYALx vjyqd9ry/2JTaIZXULjVLmQ+YFfCaLWmWV9PeCiJ1i17p35lIKCKeSXOlcNci9G9e1 8uno0pKruypU38hkQjC7n4Bs8SHTeP2n59CEs84ohZM8xbyvcXiYJq8WtP/AgUTr3F Ykpf9mJMLdIjJpjtfe25alFpdlrDgSc+VHYPBKdpe/Mxqev6vbWwZXit92qifnX1So CfdPdBW+NzlV77XoNi6IXX/ns9YHOihv4A5wnt9vUF8XRR2QXCWunnkdGKDKK3ARmC 6eTB29W/zgOHA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v10 13/26] NFS: Reduce use of uncached readdir Date: Sun, 13 Mar 2022 13:05:44 -0400 Message-Id: <20220313170557.5940-14-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220313170557.5940-13-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> <20220313170557.5940-13-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 When reading a very large directory, we want to try to keep the page cache up to date if doing so is inexpensive. With the change to allow readdir to continue reading even when the cache is incomplete, we no longer need to fall back to uncached readdir in order to scale to large directories. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 9d086ab4f889..dc6acfd14fc7 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -999,28 +999,11 @@ static int find_and_lock_cache_page(struct nfs_readdir_descriptor *desc) return res; } -static bool nfs_readdir_dont_search_cache(struct nfs_readdir_descriptor *desc) -{ - struct address_space *mapping = desc->file->f_mapping; - struct inode *dir = file_inode(desc->file); - unsigned int dtsize = NFS_SERVER(dir)->dtsize; - loff_t size = i_size_read(dir); - - /* - * Default to uncached readdir if the page cache is empty, and - * we're looking for a non-zero cookie in a large directory. - */ - return desc->dir_cookie != 0 && mapping->nrpages == 0 && size > dtsize; -} - /* Search for desc->dir_cookie from the beginning of the page cache */ static int readdir_search_pagecache(struct nfs_readdir_descriptor *desc) { int res; - if (nfs_readdir_dont_search_cache(desc)) - return -EBADCOOKIE; - do { if (desc->page_index == 0) { desc->current_index = 0; @@ -1273,10 +1256,10 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence) } if (offset != filp->f_pos) { filp->f_pos = offset; - if (!nfs_readdir_use_cookie(filp)) { + dir_ctx->page_index = 0; + if (!nfs_readdir_use_cookie(filp)) dir_ctx->dir_cookie = 0; - dir_ctx->page_index = 0; - } else + else dir_ctx->dir_cookie = offset; if (offset == 0) memset(dir_ctx->verf, 0, sizeof(dir_ctx->verf)); -- 2.35.1