NFS: nfs_refresh_inode should clear cache_validity flags on success

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>

+17 -18
+17 -18
fs/nfs/inode.c
··· 790 { 791 struct nfs_inode *nfsi = NFS_I(inode); 792 loff_t cur_size, new_isize; 793 794 795 /* Has the inode gone and changed behind our back? */ ··· 804 805 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && 806 nfsi->change_attr != fattr->change_attr) 807 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 808 809 /* Verify a few of the more important attributes */ 810 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) 811 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 812 813 cur_size = i_size_read(inode); 814 new_isize = nfs_size_to_loff_t(fattr->size); 815 if (cur_size != new_isize && nfsi->npages == 0) 816 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 817 818 /* Have any file permissions changed? */ 819 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) 820 || inode->i_uid != fattr->uid 821 || inode->i_gid != fattr->gid) 822 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; 823 824 /* Has the link count changed? */ 825 if (inode->i_nlink != fattr->nlink) 826 - nfsi->cache_validity |= NFS_INO_INVALID_ATTR; 827 828 if (!timespec_equal(&inode->i_atime, &fattr->atime)) 829 - nfsi->cache_validity |= NFS_INO_INVALID_ATIME; 830 831 nfsi->read_cache_jiffies = fattr->time_start; 832 return 0; ··· 884 { 885 struct nfs_inode *nfsi = NFS_I(inode); 886 887 - if (fattr->valid & NFS_ATTR_FATTR) { 888 - if (S_ISDIR(inode->i_mode)) { 889 - spin_lock(&inode->i_lock); 890 - nfsi->cache_validity |= NFS_INO_INVALID_DATA; 891 - spin_unlock(&inode->i_lock); 892 - } 893 - return nfs_refresh_inode(inode, fattr); 894 - } 895 - 896 spin_lock(&inode->i_lock); 897 - nfsi->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 898 if (S_ISDIR(inode->i_mode)) 899 nfsi->cache_validity |= NFS_INO_INVALID_DATA; 900 spin_unlock(&inode->i_lock); 901 - return 0; 902 } 903 904 /** ··· 937 struct nfs_server *server; 938 struct nfs_inode *nfsi = NFS_I(inode); 939 loff_t cur_isize, new_isize; 940 - unsigned int invalid = 0; 941 unsigned long now = jiffies; 942 943 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
··· 790 { 791 struct nfs_inode *nfsi = NFS_I(inode); 792 loff_t cur_size, new_isize; 793 + unsigned long invalid = 0; 794 795 796 /* Has the inode gone and changed behind our back? */ ··· 803 804 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && 805 nfsi->change_attr != fattr->change_attr) 806 + invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 807 808 /* Verify a few of the more important attributes */ 809 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) 810 + invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 811 812 cur_size = i_size_read(inode); 813 new_isize = nfs_size_to_loff_t(fattr->size); 814 if (cur_size != new_isize && nfsi->npages == 0) 815 + invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 816 817 /* Have any file permissions changed? */ 818 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) 819 || inode->i_uid != fattr->uid 820 || inode->i_gid != fattr->gid) 821 + invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; 822 823 /* Has the link count changed? */ 824 if (inode->i_nlink != fattr->nlink) 825 + invalid |= NFS_INO_INVALID_ATTR; 826 827 if (!timespec_equal(&inode->i_atime, &fattr->atime)) 828 + invalid |= NFS_INO_INVALID_ATIME; 829 + 830 + if (invalid != 0) 831 + nfsi->cache_validity |= invalid; 832 + else 833 + nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR 834 + | NFS_INO_INVALID_ATIME 835 + | NFS_INO_REVAL_PAGECACHE); 836 837 nfsi->read_cache_jiffies = fattr->time_start; 838 return 0; ··· 876 { 877 struct nfs_inode *nfsi = NFS_I(inode); 878 879 spin_lock(&inode->i_lock); 880 + nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 881 if (S_ISDIR(inode->i_mode)) 882 nfsi->cache_validity |= NFS_INO_INVALID_DATA; 883 spin_unlock(&inode->i_lock); 884 + return nfs_refresh_inode(inode, fattr); 885 } 886 887 /** ··· 938 struct nfs_server *server; 939 struct nfs_inode *nfsi = NFS_I(inode); 940 loff_t cur_isize, new_isize; 941 + unsigned long invalid = 0; 942 unsigned long now = jiffies; 943 944 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",