Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3974025pxf; Mon, 29 Mar 2021 17:20:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynUPzFqwbVvtq4rt9FDEzZPC/9TNC/xIgIzRJRqsWSHTVspgry/VuNxqR/3kq9hKaNk7Ao X-Received: by 2002:a17:907:9611:: with SMTP id gb17mr31775006ejc.325.1617063651336; Mon, 29 Mar 2021 17:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617063651; cv=none; d=google.com; s=arc-20160816; b=b0LLGCe3sJgyNKqHgWwBbYEa+gPx6v8+xFETGdgFUYciG72Z6WK5ZY587+AUDvga87 VFuMob9uTei9vRA8UWE8TQMVVqX15LGnZDivWdgfXEsx4YWFo+vs53dDS70PSzkRRE+b gA3DJOZcJEevWijp6GHn1B4p+0fpkbN2rZDq+TNTKBG+w691pKGognERCrOg4ew/Yr4K XOhdrRk7XqjPnyVUwQuFy5mjHBMxo8RIdkiGjGLtEKgZwVQyHMaUR9ieJBlyW0ANWOK4 p6pa2dZ8LvqH+MirpE6wpWLHX6OHxqY6hfKbX31k9LYV2FgD5oaX1SOoKS8wfDsw9hSl ECKA== 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=Owguc0v7SgC5s9UEAhCw8g8ElZAJUSrx2c6p6LI296o=; b=Zz7vdC3wvHu18dHuwE9JliSuOjSx66e4SFaVBbQUEVQ+a4UivFOBdSRVlzJp0V2FHg 0E4ttwIKgFaiqD9IbLBQaW6NinOha0dL5ZIUM7RSSplCOCVyn3sINBIUFUd2hEZqV9JR fSh1s2I8UScfsoLpIyc0TnWuwG/hASXeTrgiXZNCUUi4d+bhbpyrW/0e2g2O4r3y4blB ZmyhVm5jrA/PCDGpqsM8Iu8/wOuuTL8xn4LcjnHbO9L+SQnqP04L3T4EVg3asWsWlezb FdlGsJZLJwNPH7aq1mkVL24zVcQ+MmAb+668Gbtov+dOFPNcKlTXsPk1NG+KCM6G/7Ho C6ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYrNfL7N; 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 t4si14450420ejf.475.2021.03.29.17.20.29; Mon, 29 Mar 2021 17:20:51 -0700 (PDT) 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=OYrNfL7N; 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 S230202AbhC3ATO (ORCPT + 99 others); Mon, 29 Mar 2021 20:19:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:50394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbhC3ASp (ORCPT ); Mon, 29 Mar 2021 20:18:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 478C560295 for ; Tue, 30 Mar 2021 00:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617063524; bh=J67vLtRvz42GCjVC65Be19f7hcrnAW6aklVdUkkLOAo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OYrNfL7NcNSrxuV2GXWsB8NEBZzKVGzNa8s8CLOgPUl7qFq5IEfBoKW5VC1l7NWZq MK2zlaeTOVJ/Y7SSlCRBGhbQEPwG/Qsh/G8DtEr5UkKlkKPd2RZBvp+++WyTzzaXCV L+x0RBAREKugQIVYuT5qhu1fuLS1vxcjNA+Yk8jtCVIYms62ozeLovkZZx9dCFzeNT v2FNI67sXdsD1mBC5LzvYdUczWp0qlV6Rhi2pLdUhTocSYqvQPpjr+IxRzE5nR9OtT IzdEciaqNk9tUkPNtijxsVOpQfMp3P2gPP2V4Upcq3oAFs62Sl9LmSXd+wtHMi9tRR X3S1Y3+6h8ggQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 09/17] NFS: Replace use of NFS_INO_REVAL_PAGECACHE when checking cache validity Date: Mon, 29 Mar 2021 20:18:27 -0400 Message-Id: <20210330001835.41914-10-trondmy@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210330001835.41914-9-trondmy@kernel.org> References: <20210330001835.41914-1-trondmy@kernel.org> <20210330001835.41914-2-trondmy@kernel.org> <20210330001835.41914-3-trondmy@kernel.org> <20210330001835.41914-4-trondmy@kernel.org> <20210330001835.41914-5-trondmy@kernel.org> <20210330001835.41914-6-trondmy@kernel.org> <20210330001835.41914-7-trondmy@kernel.org> <20210330001835.41914-8-trondmy@kernel.org> <20210330001835.41914-9-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 When checking cache validity, be more specific than just 'we want to check the page cache validity'. In almost all cases, we want to check that change attribute, and possibly also the size. Signed-off-by: Trond Myklebust --- fs/nfs/file.c | 2 +- fs/nfs/inode.c | 19 +++++++++---------- fs/nfs/nfs4proc.c | 4 ++-- fs/nfs/write.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 16ad5050e046..1fef107961bc 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -105,7 +105,7 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp) if (filp->f_flags & O_DIRECT) goto force_reval; - if (nfs_check_cache_invalid(inode, NFS_INO_REVAL_PAGECACHE)) + if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_SIZE)) goto force_reval; return 0; force_reval: diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index be014c492c8a..484e1e3c500e 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -169,7 +169,8 @@ static bool nfs_check_cache_invalid_delegated(struct inode *inode, unsigned long unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); /* Special case for the pagecache or access cache */ - if (flags == NFS_INO_REVAL_PAGECACHE && + if (flags & (NFS_INO_INVALID_SIZE | NFS_INO_INVALID_CHANGE) && + !(flags & ~(NFS_INO_INVALID_SIZE | NFS_INO_INVALID_CHANGE)) && !(cache_validity & NFS_INO_REVAL_FORCED)) return false; return (cache_validity & flags) != 0; @@ -803,14 +804,12 @@ static u32 nfs_get_valid_attrmask(struct inode *inode) if (!(cache_validity & NFS_INO_INVALID_ATIME)) reply_mask |= STATX_ATIME; - if (!(cache_validity & NFS_INO_REVAL_PAGECACHE)) { - if (!(cache_validity & NFS_INO_INVALID_CTIME)) - reply_mask |= STATX_CTIME; - if (!(cache_validity & NFS_INO_INVALID_MTIME)) - reply_mask |= STATX_MTIME; - if (!(cache_validity & NFS_INO_INVALID_SIZE)) - reply_mask |= STATX_SIZE; - } + if (!(cache_validity & NFS_INO_INVALID_CTIME)) + reply_mask |= STATX_CTIME; + if (!(cache_validity & NFS_INO_INVALID_MTIME)) + reply_mask |= STATX_MTIME; + if (!(cache_validity & NFS_INO_INVALID_SIZE)) + reply_mask |= STATX_SIZE; if (!(cache_validity & NFS_INO_INVALID_OTHER)) reply_mask |= STATX_UID | STATX_GID | STATX_MODE | STATX_NLINK; if (!(cache_validity & NFS_INO_INVALID_BLOCKS)) @@ -1356,7 +1355,7 @@ int nfs_clear_invalid_mapping(struct address_space *mapping) bool nfs_mapping_need_revalidate_inode(struct inode *inode) { - return nfs_check_cache_invalid(inode, NFS_INO_REVAL_PAGECACHE) || + return nfs_check_cache_invalid(inode, NFS_INO_INVALID_CHANGE) || NFS_STALE(inode); } diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index b53c312fc982..2f2cea64f40a 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5451,9 +5451,9 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, goto out; } - if (cache_validity & (NFS_INO_INVALID_CHANGE | NFS_INO_REVAL_PAGECACHE)) + if (cache_validity & NFS_INO_INVALID_CHANGE) bitmask[0] |= FATTR4_WORD0_CHANGE; - if (cache_validity & (NFS_INO_INVALID_SIZE | NFS_INO_REVAL_PAGECACHE)) + if (cache_validity & NFS_INO_INVALID_SIZE) bitmask[0] |= FATTR4_WORD0_SIZE; out: for (i = 0; i < NFS4_BITMASK_SZ; i++) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index f05a90338a76..7a39b3d424da 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1293,7 +1293,7 @@ static bool nfs_write_pageuptodate(struct page *page, struct inode *inode, if (nfs_have_delegated_attributes(inode)) goto out; if (nfsi->cache_validity & - (NFS_INO_REVAL_PAGECACHE | NFS_INO_INVALID_SIZE)) + (NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE)) return false; smp_rmb(); if (test_bit(NFS_INO_INVALIDATING, &nfsi->flags) && pagelen != 0) -- 2.30.2