From patchwork Thu Feb 6 02:51:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 3592681 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8B1AFC02DC for ; Thu, 6 Feb 2014 02:51:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9DFA20142 for ; Thu, 6 Feb 2014 02:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1D0020108 for ; Thu, 6 Feb 2014 02:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754179AbaBFCvR (ORCPT ); Wed, 5 Feb 2014 21:51:17 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34708 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754125AbaBFCvQ (ORCPT ); Wed, 5 Feb 2014 21:51:16 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9107475011; Thu, 6 Feb 2014 02:51:15 +0000 (UTC) Date: Thu, 6 Feb 2014 13:51:01 +1100 From: NeilBrown To: Jeff Layton Cc: "Mkrtchyan, Tigran" , Trond Myklebust , Jim Rees , linux-nfs Subject: Re: readdir vs. getattr Message-ID: <20140206135101.1cc83442@notabene.brown> In-Reply-To: <20140206134539.53d09434@notabene.brown> References: <20130404151507.GA8484@umich.edu> <1365090480.10726.22.camel@leira.trondhjem.org> <20140129182532.7479eeda@notabene.brown> <1342984553.746756.1390987303295.JavaMail.zimbra@desy.de> <20140129071841.1979a48c@tlielax.poochiereds.net> <20140206134539.53d09434@notabene.brown> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-suse-linux-gnu) Mime-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 6 Feb 2014 13:45:39 +1100 NeilBrown wrote: > The change to nfs_update_inode fixes an issue that had me stumped for a > while. It was still sending lots of GETATTR requests even after it had > switched to READDIRPLUS instead of using cached info. So that might be a > genuine bug that should be fixed independently of this patch. I managed to post the wrong version of the patch, which didn't have this change. Sorry. Here is the real one. NeilBrown diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index be38b573495a..b237fd7f2e0e 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -845,9 +845,12 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) desc->dir_cookie = &dir_ctx->dir_cookie; desc->decode = NFS_PROTO(inode)->decode_dirent; desc->plus = nfs_use_readdirplus(inode, ctx) ? 1 : 0; + if (desc->plus && ctx->pos == 0) + clear_bit(NFS_INO_DID_FLUSH, &NFS_I(inode)->flags); nfs_block_sillyrename(dentry); - if (ctx->pos == 0 || nfs_attribute_cache_expired(inode)) + if (ctx->pos == 0 || nfs_attribute_cache_expired(inode) || + (NFS_I(inode)->cache_validity & NFS_INO_INVALID_DATA)) res = nfs_revalidate_mapping(inode, file->f_mapping); if (res < 0) goto out; @@ -1080,6 +1083,16 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags) /* Force a full look up iff the parent directory has changed */ if (!nfs_is_exclusive_create(dir, flags) && nfs_check_verifier(dir, dentry)) { + if (nfs_server_capable(dir, NFS_CAP_READDIRPLUS) + && ((NFS_I(inode)->cache_validity & + (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_LABEL)) + || nfs_attribute_cache_expired(inode)) + && !test_and_set_bit(NFS_INO_DID_FLUSH, &NFS_I(dir)->flags) + ) { + nfs_advise_use_readdirplus(dir); + goto out_zap_parent; + } + if (nfs_lookup_verify_inode(inode, flags)) goto out_zap_parent; goto out_valid; diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 28a0a3cbd3b7..3996e6c7a728 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1526,6 +1526,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) save_cache_validity = nfsi->cache_validity; nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR + | NFS_INO_INVALID_LABEL | NFS_INO_INVALID_ATIME | NFS_INO_REVAL_FORCED | NFS_INO_REVAL_PAGECACHE); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 0ae5807480f4..c282ce3e5349 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -218,6 +218,7 @@ struct nfs_inode { #define NFS_INO_COMMIT (7) /* inode is committing unstable writes */ #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */ #define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */ +#define NFS_INO_DID_FLUSH (11) static inline struct nfs_inode *NFS_I(const struct inode *inode) {