From patchwork Wed Aug 24 17:27:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Coddington X-Patchwork-Id: 9298075 X-Patchwork-Delegate: Trond.Myklebust@netapp.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 293B6607F0 for ; Wed, 24 Aug 2016 17:27:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 191BB290D9 for ; Wed, 24 Aug 2016 17:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8C6290FE; Wed, 24 Aug 2016 17:27:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94917290D9 for ; Wed, 24 Aug 2016 17:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754630AbcHXR1N (ORCPT ); Wed, 24 Aug 2016 13:27:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39636 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754589AbcHXR1L (ORCPT ); Wed, 24 Aug 2016 13:27:11 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7F51C00B8C6; Wed, 24 Aug 2016 17:27:10 +0000 (UTC) Received: from bcodding.csb (vpn-63-45.rdu2.redhat.com [10.10.63.45]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7OHRA4l009450; Wed, 24 Aug 2016 13:27:10 -0400 Received: by bcodding.csb (Postfix, from userid 24008) id 5F1B810A0D3C; Wed, 24 Aug 2016 13:27:09 -0400 (EDT) From: Benjamin Coddington To: linux-nfs@vger.kernel.org Cc: Trond Myklebust , Anna Schumaker , Scott Mayhew Subject: [PATCH] NFS: Don't invalidate directory mapping until attributes expire Date: Wed, 24 Aug 2016 13:27:09 -0400 Message-Id: <67cfa1f7f028229bfd4b1ac2619bc85b9e34ef7f.1472059583.git.bcodding@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 24 Aug 2016 17:27:10 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 311324ad1713666a6e803aecf0d4e1a136a5b34a ("NFS: Be more aggressive in using readdirplus for 'ls -l' situations") removed the optimization added by commit 07b5ce8ef2d87f1914054804720d6facbaa3f4ce ("NFS: Make nfs_readdir revalidate less often") to bypass the revalidation of the directory mapping on subsequent calls into nfs_readdir(). Add that optimization back here. A directory modified once every second and containing 40k entries takes my system around 80 seconds to list. With this patch, that time is reduced to 7 seconds. Signed-off-by: Benjamin Coddington --- fs/nfs/dir.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 19d93d0cd400..9a036dc6caa3 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -872,17 +872,6 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc) goto out; } -static bool nfs_dir_mapping_need_revalidate(struct inode *dir) -{ - struct nfs_inode *nfsi = NFS_I(dir); - - if (nfs_attribute_cache_expired(dir)) - return true; - if (nfsi->cache_validity & NFS_INO_INVALID_DATA) - return true; - return false; -} - /* The file offset position represents the dirent entry number. A last cookie cache takes care of the common case of reading the whole directory. @@ -914,7 +903,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) desc->decode = NFS_PROTO(inode)->decode_dirent; desc->plus = nfs_use_readdirplus(inode, ctx) ? 1 : 0; - if (ctx->pos == 0 || nfs_dir_mapping_need_revalidate(inode)) + if (ctx->pos == 0 || nfs_attribute_cache_expired(inode)) res = nfs_revalidate_mapping(inode, file->f_mapping); if (res < 0) goto out;