From patchwork Fri Aug 26 15:37:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Coddington X-Patchwork-Id: 9301649 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 84668607EE for ; Fri, 26 Aug 2016 15:38:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F21294D9 for ; Fri, 26 Aug 2016 15:38:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ADA02961A; Fri, 26 Aug 2016 15:38:27 +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 17583294D9 for ; Fri, 26 Aug 2016 15:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753535AbcHZPiZ (ORCPT ); Fri, 26 Aug 2016 11:38:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751559AbcHZPiZ (ORCPT ); Fri, 26 Aug 2016 11:38:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 6164A4E4C8; Fri, 26 Aug 2016 15:37:39 +0000 (UTC) Received: from bcodding.csb (vpn-62-141.rdu2.redhat.com [10.10.62.141]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7QFbcOJ000360; Fri, 26 Aug 2016 11:37:39 -0400 Received: by bcodding.csb (Postfix, from userid 24008) id E36E310A0D40; Fri, 26 Aug 2016 11:37:37 -0400 (EDT) From: Benjamin Coddington To: linux-nfs@vger.kernel.org Cc: Trond Myklebust , Anna Schumaker , Scott@redhat.com, "Mayhew References: <67cfa1f7f028229bfd4b1ac2619bc85b9e34ef7f.1472059583.git.bcodding@redhat.com> In-Reply-To: <67cfa1f7f028229bfd4b1ac2619bc85b9e34ef7f.1472059583.git.bcodding@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 26 Aug 2016 15:37:39 +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 This approach uses another bit in the inode flags.. if that's too expensive for this ls -l optimization, I will look for another way. Change from v1: Doesn't completely break the commit 311324ad1713 functionality. 8<----------------------------------------------------------------------------- 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 | 3 ++- include/linux/nfs_fs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 19d93d0cd400..88f5dd561025 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -477,6 +477,7 @@ void nfs_force_use_readdirplus(struct inode *dir) { if (!list_empty(&NFS_I(dir)->open_files)) { nfs_advise_use_readdirplus(dir); + set_bit(NFS_INO_FORCE_RDPLUS, &NFS_I(dir)->flags); nfs_zap_mapping(dir, dir->i_mapping); } } @@ -878,7 +879,7 @@ static bool nfs_dir_mapping_need_revalidate(struct inode *dir) if (nfs_attribute_cache_expired(dir)) return true; - if (nfsi->cache_validity & NFS_INO_INVALID_DATA) + if (test_and_clear_bit(NFS_INO_FORCE_RDPLUS, &nfsi->flags)) return true; return false; } diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index d71278c3c5bd..729cddb7364f 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -211,6 +211,7 @@ struct nfs_inode { #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */ #define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */ #define NFS_INO_LAYOUTSTATS (11) /* layoutstats inflight */ +#define NFS_INO_FORCE_RDPLUS (12) /* force readdirplus */ static inline struct nfs_inode *NFS_I(const struct inode *inode) {