Skip to content

Commit

Permalink
NFS: nfs_refresh_inode should clear cache_validity flags on success
Browse files Browse the repository at this point in the history
If the cached attributes match the ones supplied in the fattr, then assume
we've revalidated the inode.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 9, 2007
1 parent 40d2470 commit 2a3f5fd
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
{
struct nfs_inode *nfsi = NFS_I(inode);
loff_t cur_size, new_isize;
unsigned long invalid = 0;


/* Has the inode gone and changed behind our back? */
Expand All @@ -803,29 +804,36 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat

if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 &&
nfsi->change_attr != fattr->change_attr)
nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;

/* Verify a few of the more important attributes */
if (!timespec_equal(&inode->i_mtime, &fattr->mtime))
nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;

cur_size = i_size_read(inode);
new_isize = nfs_size_to_loff_t(fattr->size);
if (cur_size != new_isize && nfsi->npages == 0)
nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;

/* Have any file permissions changed? */
if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
|| inode->i_uid != fattr->uid
|| inode->i_gid != fattr->gid)
nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;

/* Has the link count changed? */
if (inode->i_nlink != fattr->nlink)
nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
invalid |= NFS_INO_INVALID_ATTR;

if (!timespec_equal(&inode->i_atime, &fattr->atime))
nfsi->cache_validity |= NFS_INO_INVALID_ATIME;
invalid |= NFS_INO_INVALID_ATIME;

if (invalid != 0)
nfsi->cache_validity |= invalid;
else
nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR
| NFS_INO_INVALID_ATIME
| NFS_INO_REVAL_PAGECACHE);

nfsi->read_cache_jiffies = fattr->time_start;
return 0;
Expand Down Expand Up @@ -876,21 +884,12 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
{
struct nfs_inode *nfsi = NFS_I(inode);

if (fattr->valid & NFS_ATTR_FATTR) {
if (S_ISDIR(inode->i_mode)) {
spin_lock(&inode->i_lock);
nfsi->cache_validity |= NFS_INO_INVALID_DATA;
spin_unlock(&inode->i_lock);
}
return nfs_refresh_inode(inode, fattr);
}

spin_lock(&inode->i_lock);
nfsi->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
if (S_ISDIR(inode->i_mode))
nfsi->cache_validity |= NFS_INO_INVALID_DATA;
spin_unlock(&inode->i_lock);
return 0;
return nfs_refresh_inode(inode, fattr);
}

/**
Expand Down Expand Up @@ -938,7 +937,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
struct nfs_server *server;
struct nfs_inode *nfsi = NFS_I(inode);
loff_t cur_isize, new_isize;
unsigned int invalid = 0;
unsigned long invalid = 0;
unsigned long now = jiffies;

dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
Expand Down

0 comments on commit 2a3f5fd

Please sign in to comment.