Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2014676pxb; Mon, 8 Mar 2021 11:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwU7TZfi+oXCJGxoO/OwDseKIX0NfdS5mcigf9coeMXDT6D4wnZ2FCTk+UX9szFdBXG70a+ X-Received: by 2002:a05:6402:1691:: with SMTP id a17mr207330edv.336.1615232659856; Mon, 08 Mar 2021 11:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615232659; cv=none; d=google.com; s=arc-20160816; b=bUzDqsZFZSmzzXdAhsMCoiwUASY5RHSu+WaML0LBF8D3I1SQeGJ8OdN+awpY1nHG+J KSY6x/XcjhVj03QAoOK8jAkHJRxYNVNJ4ArqDjIlfDayXCtEuu/BB3X47/bJ/DyPx6OU sih1GSyDGM2aB9iAVepewdhCqTO38e1SXLp8oR3Wu2ep/uaDegEgp+NSL3iqenxmdA2s k/Yl6a1AbtJvsJ3wMPbSOeRshtWpe55/MWZ+jHB2Et5Hv82wUriWOQYDo855Qums+Z+Q 1ypY+SzxTO9iK8p+UGqN2nKIWgr7gWD9cFrx9IpvLHyqUYgKO/lPcjBR0K8PDt1ZRf+d tlGg== 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:cc:to:from :dkim-signature; bh=Vo1SjCldzCZOoNqQxLIWRjlJV2Siz3TZycUVHaBpjSI=; b=G2R4zTd0cbCa2Jeim72lp7ZYolVirYs5r+HwXYSoOXpLgbrUDK/Q3tAJaEKdINNdU+ yl0Ocgah83nKLYxDyI/R70iWB9q7KHEYnrsEVi7XIcZ6C88qp9EQ0AiREuHYA3VAAp4h DNZlJCZ6Je9SxcBP0HVlPw3WVK8E9oCDfVIww7I1GQ5boJOVCkFbQyKXzXGAwIaxwQio 4onVdtXwqjgubOuYinFko5TimwZbMA7yO/l9lEzBja3xWkT0/bPeQp+h/maP+jXVTrFr /gdPnucwpLfWO+LqhdMBO0pRF5X/4nbOla+t0BiHt+mf4n29w1+vAl6kS5h1PiQrAuVW ecnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Di5Vnf33; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si7863314eds.443.2021.03.08.11.43.46; Mon, 08 Mar 2021 11:44:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Di5Vnf33; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbhCHTnM (ORCPT + 99 others); Mon, 8 Mar 2021 14:43:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:51024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbhCHTm6 (ORCPT ); Mon, 8 Mar 2021 14:42:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3031E652AC; Mon, 8 Mar 2021 19:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615232578; bh=L0Wr9TfqAZnW5Uf3pPdj2QB5+gEcD0shx11hM0QzNlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Di5Vnf339+yEN4rYFHPSeAtR/WWnYOodRWR9rmNjtXDubmBkKsWNIE88rbM5M2AKQ 1w0LhW/CBfCzhMlkYMAyF+27uajGd0GkHSbWMH4yWIx/0pJEafh9dVRMXLS9s7BTYr 1X0Grxcd3pZ8Tuxmaku0zUGXkjWlcn/hKP3zbW+fzmshgSkvLaDtjUhMN1tn83fJFH 1oT7M53AtRsXyL0ICBuA0jM+NpXY1/E329fUeOeWW2kuBYaLjoYactWQf/m1IiP4iL kmUFzelSrwOFp6x+Kvg+r1Ip6FknU+yEtb7+Iz+304mD6tptTUrFbkO1fU+DVYspbT yCv7gpX82tWkQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Cc: Geert Jansen Subject: [PATCH v2 4/5] NFS: Fix open coded versions of nfs_set_cache_invalid() Date: Mon, 8 Mar 2021 14:42:54 -0500 Message-Id: <20210308194255.7873-4-trondmy@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308194255.7873-3-trondmy@kernel.org> References: <20210308194255.7873-1-trondmy@kernel.org> <20210308194255.7873-2-trondmy@kernel.org> <20210308194255.7873-3-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust nfs_set_cache_invalid() has code to handle delegations, and other optimisations, so let's use it when appropriate. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 20 ++++++++++---------- fs/nfs/inode.c | 4 ++-- fs/nfs/unlink.c | 6 +++--- fs/nfs/write.c | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 02ac982846f4..fc4f490f2d78 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -81,8 +81,9 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir spin_lock(&dir->i_lock); if (list_empty(&nfsi->open_files) && (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER)) - nfsi->cache_validity |= NFS_INO_INVALID_DATA | - NFS_INO_REVAL_FORCED; + nfs_set_cache_invalid(dir, + NFS_INO_INVALID_DATA | + NFS_INO_REVAL_FORCED); list_add(&ctx->list, &nfsi->open_files); spin_unlock(&dir->i_lock); return ctx; @@ -1700,10 +1701,9 @@ static void nfs_drop_nlink(struct inode *inode) if (inode->i_nlink > 0) drop_nlink(inode); NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter(); - NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE - | NFS_INO_INVALID_CTIME - | NFS_INO_INVALID_OTHER - | NFS_INO_REVAL_FORCED; + nfs_set_cache_invalid( + inode, NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME | + NFS_INO_INVALID_OTHER | NFS_INO_REVAL_FORCED); spin_unlock(&inode->i_lock); } @@ -1715,7 +1715,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) { if (S_ISDIR(inode->i_mode)) /* drop any readdir cache as it could easily be old */ - NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA; + nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA); if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { nfs_complete_unlink(dentry, inode); @@ -2481,9 +2481,9 @@ int nfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir, if (error == 0) { spin_lock(&old_inode->i_lock); NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter(); - NFS_I(old_inode)->cache_validity |= NFS_INO_INVALID_CHANGE - | NFS_INO_INVALID_CTIME - | NFS_INO_REVAL_FORCED; + nfs_set_cache_invalid(old_inode, NFS_INO_INVALID_CHANGE | + NFS_INO_INVALID_CTIME | + NFS_INO_REVAL_FORCED); spin_unlock(&old_inode->i_lock); } out: diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index d21bfaac10b0..eb1ae77f411a 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1067,8 +1067,8 @@ void nfs_inode_attach_open_context(struct nfs_open_context *ctx) spin_lock(&inode->i_lock); if (list_empty(&nfsi->open_files) && (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER)) - nfsi->cache_validity |= NFS_INO_INVALID_DATA | - NFS_INO_REVAL_FORCED; + nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA | + NFS_INO_REVAL_FORCED); list_add_tail_rcu(&ctx->list, &nfsi->open_files); spin_unlock(&inode->i_lock); } diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index b27ebdccef70..5fa11e1aca4c 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -500,9 +500,9 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry) nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); spin_lock(&inode->i_lock); NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter(); - NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE - | NFS_INO_INVALID_CTIME - | NFS_INO_REVAL_FORCED; + nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE | + NFS_INO_INVALID_CTIME | + NFS_INO_REVAL_FORCED); spin_unlock(&inode->i_lock); d_move(dentry, sdentry); break; diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 82bdcb982186..f05a90338a76 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -303,9 +303,9 @@ static void nfs_set_pageerror(struct address_space *mapping) nfs_zap_mapping(mapping->host, mapping); /* Force file size revalidation */ spin_lock(&inode->i_lock); - NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED | - NFS_INO_REVAL_PAGECACHE | - NFS_INO_INVALID_SIZE; + nfs_set_cache_invalid(inode, NFS_INO_REVAL_FORCED | + NFS_INO_REVAL_PAGECACHE | + NFS_INO_INVALID_SIZE); spin_unlock(&inode->i_lock); } @@ -1604,7 +1604,7 @@ static int nfs_writeback_done(struct rpc_task *task, /* Deal with the suid/sgid bit corner case */ if (nfs_should_remove_suid(inode)) { spin_lock(&inode->i_lock); - NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER; + nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER); spin_unlock(&inode->i_lock); } return 0; -- 2.29.2