Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp606270pxm; Fri, 25 Feb 2022 15:01:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+VHZtM7AowecTRP6ouI0k1WL6hH4U7/d089OxyyQk5Z1mpoxRYqmb2uH+M/+XDW9YqpX8 X-Received: by 2002:aa7:8882:0:b0:4df:7b9e:1ccb with SMTP id z2-20020aa78882000000b004df7b9e1ccbmr9968301pfe.41.1645830071103; Fri, 25 Feb 2022 15:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645830071; cv=none; d=google.com; s=arc-20160816; b=qkS236THq8y7TShMVe8znGB1G/ri5aVXfYKf5ZmuoO6kfI5Ewylu9BRk8L/nxFgYLe OUmR5Bf3dw1litfFLADQlMUBUrAy+IezqxHvBlKta+ktXz3mzR2lraYv2wsmbLbpAY+W x+mexWNnkeyzymdSrfa5xUSHfZZsPoN2tArRL+W6AmELVG7Mc837QPZYSqZdveTw/xbH qUzl9xI9dEC1Vz89wPEVIaERuyjgj8C1j8b74hf05yLRcMMVf8IuZXsxNGuhbWRk4UOQ JDPve7cnWuEXa9q17BKaZk7sF5Sg3fgM3Iqi5Ctnhf8Js5GFcAiP5j8QE1EI8Wk+hrkW Y7mQ== 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=jAf+BpDeK9Kn81X7VdnZ+9H4LcwjLJvoTvAZJQlZE+g=; b=MiTg9pKMTPwIYIGF+gB3awpDMKvVY+1m+Kf9l9Zpg+vn4hSpcPd5ACIfiES9/RbsOn AnFzz1sCA1tuRD7k3V9BsVdMtRphq4/YZwPKRVbn+68TVjFuDq6OSp4Oa95oHe7No0rs afWr5x7iumxOoESBy5AUL3tFaUM/y6eAZfuf+q10bjC+9jMTpm1s5hwQe34YKXGnzyuK /3Ibhxr6kOTVlf+UfdIY/x3fxZkRNwKUXNCyD7Ym2zdrEIS0Lb8Gh5fBNWZ78T876HGj Ic6ClzUjAefwxY/Y+mh1CzgGkdQLOSSVNzqV0zbCg1ioPGqvDoknUf9T/MfO7DkwybMV eoHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hMEBHZ0K; 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 c185-20020a6335c2000000b00373b68e9673si3239345pga.727.2022.02.25.15.00.17; Fri, 25 Feb 2022 15:01:11 -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=hMEBHZ0K; 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 S233385AbiBYSfW (ORCPT + 99 others); Fri, 25 Feb 2022 13:35:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233375AbiBYSfQ (ORCPT ); Fri, 25 Feb 2022 13:35:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65EBE1AAA53 for ; Fri, 25 Feb 2022 10:34:42 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1DC4DB83308 for ; Fri, 25 Feb 2022 18:34:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95A9EC340F1 for ; Fri, 25 Feb 2022 18:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645814080; bh=OiFNVdnDpPaKpdskCdO53xgbGuUF9Blf9zplN9ZKsvU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hMEBHZ0K2b/hz7IS4VnLZNA2N+8fLvRYqR5g+KAl00Robzz5hP6BhDhh0F9OrKNEI VF2ua4enPdfnWaSNmUcqpxkqWIV5N4vfO1n1OVgVOXEDORcXSEQIj28fnJbA1kb7cj Djj8GCXhOmDiGv6TOa3/vs8MG7KDUt2u34/t1NUx2c1NdtIGxfcOCEbjQLsV6wbUy8 j8yRwArpEMzaIBaPWgXT4i2iMXvcZvTksTGpr1q/uZw/jJpBhjmYz8G8BdeRI/Z8Gj X95JNzISChRADIP4CB6CvdrgM91ygGGtyJJP28R02Oi9vTq3wKkdeEZ3JUkwd8Tfne LiGHoZjGVhaLg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v8 12/24] NFS: Reduce use of uncached readdir Date: Fri, 25 Feb 2022 13:28:17 -0500 Message-Id: <20220225182829.1236093-13-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220225182829.1236093-12-trondmy@kernel.org> References: <20220225182829.1236093-1-trondmy@kernel.org> <20220225182829.1236093-2-trondmy@kernel.org> <20220225182829.1236093-3-trondmy@kernel.org> <20220225182829.1236093-4-trondmy@kernel.org> <20220225182829.1236093-5-trondmy@kernel.org> <20220225182829.1236093-6-trondmy@kernel.org> <20220225182829.1236093-7-trondmy@kernel.org> <20220225182829.1236093-8-trondmy@kernel.org> <20220225182829.1236093-9-trondmy@kernel.org> <20220225182829.1236093-10-trondmy@kernel.org> <20220225182829.1236093-11-trondmy@kernel.org> <20220225182829.1236093-12-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 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 1c79244115f0..03ba892bb195 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -989,28 +989,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; @@ -1260,10 +1243,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