NFS: Replace use of NFS_INO_REVAL_PAGECACHE when checking cache validity
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 <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
1f3208b2d6
commit
13c0b082b6
|
@ -105,7 +105,7 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
|
||||||
|
|
||||||
if (filp->f_flags & O_DIRECT)
|
if (filp->f_flags & O_DIRECT)
|
||||||
goto force_reval;
|
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;
|
goto force_reval;
|
||||||
return 0;
|
return 0;
|
||||||
force_reval:
|
force_reval:
|
||||||
|
|
|
@ -164,34 +164,19 @@ static int nfs_attribute_timeout(struct inode *inode)
|
||||||
return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
|
return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nfs_check_cache_invalid_delegated(struct inode *inode, unsigned long flags)
|
static bool nfs_check_cache_flags_invalid(struct inode *inode,
|
||||||
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
|
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 &&
|
|
||||||
!(cache_validity & NFS_INO_REVAL_FORCED))
|
|
||||||
return false;
|
|
||||||
return (cache_validity & flags) != 0;
|
return (cache_validity & flags) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nfs_check_cache_invalid_not_delegated(struct inode *inode, unsigned long flags)
|
|
||||||
{
|
|
||||||
unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
|
|
||||||
|
|
||||||
if ((cache_validity & flags) != 0)
|
|
||||||
return true;
|
|
||||||
if (nfs_attribute_timeout(inode))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool nfs_check_cache_invalid(struct inode *inode, unsigned long flags)
|
bool nfs_check_cache_invalid(struct inode *inode, unsigned long flags)
|
||||||
{
|
{
|
||||||
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
|
if (nfs_check_cache_flags_invalid(inode, flags))
|
||||||
return nfs_check_cache_invalid_delegated(inode, flags);
|
return true;
|
||||||
|
return nfs_attribute_cache_expired(inode);
|
||||||
return nfs_check_cache_invalid_not_delegated(inode, flags);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(nfs_check_cache_invalid);
|
EXPORT_SYMBOL_GPL(nfs_check_cache_invalid);
|
||||||
|
|
||||||
|
@ -809,14 +794,12 @@ static u32 nfs_get_valid_attrmask(struct inode *inode)
|
||||||
|
|
||||||
if (!(cache_validity & NFS_INO_INVALID_ATIME))
|
if (!(cache_validity & NFS_INO_INVALID_ATIME))
|
||||||
reply_mask |= STATX_ATIME;
|
reply_mask |= STATX_ATIME;
|
||||||
if (!(cache_validity & NFS_INO_REVAL_PAGECACHE)) {
|
|
||||||
if (!(cache_validity & NFS_INO_INVALID_CTIME))
|
if (!(cache_validity & NFS_INO_INVALID_CTIME))
|
||||||
reply_mask |= STATX_CTIME;
|
reply_mask |= STATX_CTIME;
|
||||||
if (!(cache_validity & NFS_INO_INVALID_MTIME))
|
if (!(cache_validity & NFS_INO_INVALID_MTIME))
|
||||||
reply_mask |= STATX_MTIME;
|
reply_mask |= STATX_MTIME;
|
||||||
if (!(cache_validity & NFS_INO_INVALID_SIZE))
|
if (!(cache_validity & NFS_INO_INVALID_SIZE))
|
||||||
reply_mask |= STATX_SIZE;
|
reply_mask |= STATX_SIZE;
|
||||||
}
|
|
||||||
if (!(cache_validity & NFS_INO_INVALID_OTHER))
|
if (!(cache_validity & NFS_INO_INVALID_OTHER))
|
||||||
reply_mask |= STATX_UID | STATX_GID | STATX_MODE | STATX_NLINK;
|
reply_mask |= STATX_UID | STATX_GID | STATX_MODE | STATX_NLINK;
|
||||||
if (!(cache_validity & NFS_INO_INVALID_BLOCKS))
|
if (!(cache_validity & NFS_INO_INVALID_BLOCKS))
|
||||||
|
@ -1362,7 +1345,7 @@ out:
|
||||||
|
|
||||||
bool nfs_mapping_need_revalidate_inode(struct inode *inode)
|
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);
|
NFS_STALE(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5429,7 +5429,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,
|
||||||
|
|
||||||
memcpy(bitmask, src, sizeof(*bitmask) * NFS4_BITMASK_SZ);
|
memcpy(bitmask, src, sizeof(*bitmask) * NFS4_BITMASK_SZ);
|
||||||
|
|
||||||
if (cache_validity & (NFS_INO_INVALID_CHANGE | NFS_INO_REVAL_PAGECACHE))
|
if (cache_validity & NFS_INO_INVALID_CHANGE)
|
||||||
bitmask[0] |= FATTR4_WORD0_CHANGE;
|
bitmask[0] |= FATTR4_WORD0_CHANGE;
|
||||||
if (cache_validity & NFS_INO_INVALID_ATIME)
|
if (cache_validity & NFS_INO_INVALID_ATIME)
|
||||||
bitmask[1] |= FATTR4_WORD1_TIME_ACCESS;
|
bitmask[1] |= FATTR4_WORD1_TIME_ACCESS;
|
||||||
|
@ -5449,8 +5449,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,
|
||||||
if (nfs4_have_delegation(inode, FMODE_READ) &&
|
if (nfs4_have_delegation(inode, FMODE_READ) &&
|
||||||
!(cache_validity & NFS_INO_REVAL_FORCED))
|
!(cache_validity & NFS_INO_REVAL_FORCED))
|
||||||
bitmask[0] &= ~FATTR4_WORD0_SIZE;
|
bitmask[0] &= ~FATTR4_WORD0_SIZE;
|
||||||
else if (cache_validity &
|
else if (cache_validity & NFS_INO_INVALID_SIZE)
|
||||||
(NFS_INO_INVALID_SIZE | NFS_INO_REVAL_PAGECACHE))
|
|
||||||
bitmask[0] |= FATTR4_WORD0_SIZE;
|
bitmask[0] |= FATTR4_WORD0_SIZE;
|
||||||
|
|
||||||
for (i = 0; i < NFS4_BITMASK_SZ; i++)
|
for (i = 0; i < NFS4_BITMASK_SZ; i++)
|
||||||
|
|
|
@ -1293,7 +1293,7 @@ static bool nfs_write_pageuptodate(struct page *page, struct inode *inode,
|
||||||
if (nfs_have_delegated_attributes(inode))
|
if (nfs_have_delegated_attributes(inode))
|
||||||
goto out;
|
goto out;
|
||||||
if (nfsi->cache_validity &
|
if (nfsi->cache_validity &
|
||||||
(NFS_INO_REVAL_PAGECACHE | NFS_INO_INVALID_SIZE))
|
(NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE))
|
||||||
return false;
|
return false;
|
||||||
smp_rmb();
|
smp_rmb();
|
||||||
if (test_bit(NFS_INO_INVALIDATING, &nfsi->flags) && pagelen != 0)
|
if (test_bit(NFS_INO_INVALIDATING, &nfsi->flags) && pagelen != 0)
|
||||||
|
|
Loading…
Reference in New Issue