diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-10-08 14:26:13 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-10-09 17:20:50 -0400 |
commit | 2a3f5fd45938bd86ce8faf4cb26be4f7e9ae2941 (patch) | |
tree | 84ed5c302b9a126fae440faa6cda0494ce4ca36b /fs/nfs/inode.c | |
parent | 40d24704091c8a29a4c99d25670f1996749aea6f (diff) |
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>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index c44cd02e5181..cad1246bf575 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -790,6 +790,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
790 | { | 790 | { |
791 | struct nfs_inode *nfsi = NFS_I(inode); | 791 | struct nfs_inode *nfsi = NFS_I(inode); |
792 | loff_t cur_size, new_isize; | 792 | loff_t cur_size, new_isize; |
793 | unsigned long invalid = 0; | ||
793 | 794 | ||
794 | 795 | ||
795 | /* Has the inode gone and changed behind our back? */ | 796 | /* Has the inode gone and changed behind our back? */ |
@@ -803,29 +804,36 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
803 | 804 | ||
804 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && | 805 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && |
805 | nfsi->change_attr != fattr->change_attr) | 806 | nfsi->change_attr != fattr->change_attr) |
806 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 807 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
807 | 808 | ||
808 | /* Verify a few of the more important attributes */ | 809 | /* Verify a few of the more important attributes */ |
809 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) | 810 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) |
810 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 811 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
811 | 812 | ||
812 | cur_size = i_size_read(inode); | 813 | cur_size = i_size_read(inode); |
813 | new_isize = nfs_size_to_loff_t(fattr->size); | 814 | new_isize = nfs_size_to_loff_t(fattr->size); |
814 | if (cur_size != new_isize && nfsi->npages == 0) | 815 | if (cur_size != new_isize && nfsi->npages == 0) |
815 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 816 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
816 | 817 | ||
817 | /* Have any file permissions changed? */ | 818 | /* Have any file permissions changed? */ |
818 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) | 819 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) |
819 | || inode->i_uid != fattr->uid | 820 | || inode->i_uid != fattr->uid |
820 | || inode->i_gid != fattr->gid) | 821 | || inode->i_gid != fattr->gid) |
821 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; | 822 | invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; |
822 | 823 | ||
823 | /* Has the link count changed? */ | 824 | /* Has the link count changed? */ |
824 | if (inode->i_nlink != fattr->nlink) | 825 | if (inode->i_nlink != fattr->nlink) |
825 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | 826 | invalid |= NFS_INO_INVALID_ATTR; |
826 | 827 | ||
827 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) | 828 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) |
828 | nfsi->cache_validity |= NFS_INO_INVALID_ATIME; | 829 | invalid |= NFS_INO_INVALID_ATIME; |
830 | |||
831 | if (invalid != 0) | ||
832 | nfsi->cache_validity |= invalid; | ||
833 | else | ||
834 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR | ||
835 | | NFS_INO_INVALID_ATIME | ||
836 | | NFS_INO_REVAL_PAGECACHE); | ||
829 | 837 | ||
830 | nfsi->read_cache_jiffies = fattr->time_start; | 838 | nfsi->read_cache_jiffies = fattr->time_start; |
831 | return 0; | 839 | return 0; |
@@ -876,21 +884,12 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
876 | { | 884 | { |
877 | struct nfs_inode *nfsi = NFS_I(inode); | 885 | struct nfs_inode *nfsi = NFS_I(inode); |
878 | 886 | ||
879 | if (fattr->valid & NFS_ATTR_FATTR) { | ||
880 | if (S_ISDIR(inode->i_mode)) { | ||
881 | spin_lock(&inode->i_lock); | ||
882 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | ||
883 | spin_unlock(&inode->i_lock); | ||
884 | } | ||
885 | return nfs_refresh_inode(inode, fattr); | ||
886 | } | ||
887 | |||
888 | spin_lock(&inode->i_lock); | 887 | spin_lock(&inode->i_lock); |
889 | nfsi->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 888 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
890 | if (S_ISDIR(inode->i_mode)) | 889 | if (S_ISDIR(inode->i_mode)) |
891 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | 890 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
892 | spin_unlock(&inode->i_lock); | 891 | spin_unlock(&inode->i_lock); |
893 | return 0; | 892 | return nfs_refresh_inode(inode, fattr); |
894 | } | 893 | } |
895 | 894 | ||
896 | /** | 895 | /** |
@@ -938,7 +937,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
938 | struct nfs_server *server; | 937 | struct nfs_server *server; |
939 | struct nfs_inode *nfsi = NFS_I(inode); | 938 | struct nfs_inode *nfsi = NFS_I(inode); |
940 | loff_t cur_isize, new_isize; | 939 | loff_t cur_isize, new_isize; |
941 | unsigned int invalid = 0; | 940 | unsigned long invalid = 0; |
942 | unsigned long now = jiffies; | 941 | unsigned long now = jiffies; |
943 | 942 | ||
944 | dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n", | 943 | dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n", |