Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1073494pxm; Wed, 23 Feb 2022 17:25:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhiTGAhEyUn2BeMBVAWb4Lr6ls5UajYwuTu420uftHG3q/d5IYPbEeNdauYA1wVX1GQAJB X-Received: by 2002:a17:902:f647:b0:14f:c37d:34ec with SMTP id m7-20020a170902f64700b0014fc37d34ecmr250872plg.6.1645665931213; Wed, 23 Feb 2022 17:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645665931; cv=none; d=google.com; s=arc-20160816; b=Hbxa4Y8CZEpVPH0TGgvkUfDTXDKlPHktQJvYbMVzWCPDw4Y5RAbMsGkxhmtv1UMlT4 M+11MgX6HtAJoCeCm1/CyASu5YpCgqZoC3jiIew9S8Hg+SZJBd28t2/v+eMKIReNb9pp Uqz2IlGRE1hH8VuLo3pSWSr56MrdyFopJJ4igjErUdUFRslaopWsr6UuLCa2zt16kcW+ DNttFmwK4JXD1XmPM9tvWcs7doRhIAALkLA8Dy2vYFc/O9kSIqyb91AZeZ/NPzFqGgfe k9zm83opVODeOwIZebzm1pwxyKctHlD/n+HSKK2/uJuN5vmfxaUY6a8G72g/LCLLc16r 9eag== 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=eh3Ns/oJQeZJ4SMUAcoeu3tLIZwiTqwno0ZB6BNSYPs=; b=g7URIYlzoxyOMbn+NDYQlPXnmkRJ3lSjpW5Gm55aId3bWbUCP0kYLjz84QX+zT8sMP hzK4iEXb91O1OmhVXPfNurPMMP0XoinataCp2Xua9vijXXqov36R54oEOP5+27jtRIIQ rhuYMhcMCP9h2gO3E3708W4SB74Cckx/IHwr1EFit09AxBtAQtnFNWiLWTz2Oc9vQMGQ cxEt6ML0GANpMjzqJgsfl52h8r/oXBHEPZGw2H/NoLEV2F6isiUtCvKDO4OCwFrq5zsD yohqfAzjks6NVZQqiP1errCS07IMT48cmMoH6oQ9JalI+x03217vhxIkFgnMLHNKQihP xFmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QpL1TX5H; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v12si1029993ple.586.2022.02.23.17.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:25:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QpL1TX5H; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5062B10BBD2; Wed, 23 Feb 2022 17:07:06 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242403AbiBWVUI (ORCPT + 99 others); Wed, 23 Feb 2022 16:20:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242442AbiBWVUF (ORCPT ); Wed, 23 Feb 2022 16:20:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F09A14ECC9 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 7FBEA6189F for ; Wed, 23 Feb 2022 21:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B40D3C340F1 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=1GcyI+UqjembG1jSn4h6EOLLDldBloU94xugDNPI6P4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QpL1TX5HHMcuIZSU/EY8iMY9aqZFf0NeoGEwjjWwqWQ+tzouY/iL5hdn4t6AZJK8L g9VSxSawKaZOnWlDMUfMxmdvDgted4betGTUtQfy45JLc2cn3dqR52AyJ104fOyXuQ LM1SVGvsoqA9A0qupHbT2b3Jgu75m9Z7spdR/HsgvrMBh5Yp+DhpGpoPdlKT8PMYBA RBqEupYwpRnNDeTjJS4xYeryidM00kvV98ajLH2Otp3nEVAPIJx10xXDNGqd6y6Jt5 cmomDQGEzY5VvEldvxG0EBR/m8XRUjQ5uLSHpMJG4N0ytyz4C0XBUG4IPPRp7aMxlf /U8mbU2t4R2JQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v7 10/21] NFS: Reduce use of uncached readdir Date: Wed, 23 Feb 2022 16:12:54 -0500 Message-Id: <20220223211305.296816-11-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220223211305.296816-10-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> <20220223211305.296816-10-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 9b0f13b52dbf..982b5dbe30d7 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -986,28 +986,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; @@ -1262,10 +1245,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