diff options
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 197 |
1 files changed, 128 insertions, 69 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 4845911f1c63..541b418327c8 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -615,14 +615,18 @@ nfs_zap_caches(struct inode *inode) | |||
615 | struct nfs_inode *nfsi = NFS_I(inode); | 615 | struct nfs_inode *nfsi = NFS_I(inode); |
616 | int mode = inode->i_mode; | 616 | int mode = inode->i_mode; |
617 | 617 | ||
618 | spin_lock(&inode->i_lock); | ||
619 | |||
618 | NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); | 620 | NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); |
619 | NFS_ATTRTIMEO_UPDATE(inode) = jiffies; | 621 | NFS_ATTRTIMEO_UPDATE(inode) = jiffies; |
620 | 622 | ||
621 | memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); | 623 | memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); |
622 | if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) | 624 | if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) |
623 | nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; | 625 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; |
624 | else | 626 | else |
625 | nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; | 627 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; |
628 | |||
629 | spin_unlock(&inode->i_lock); | ||
626 | } | 630 | } |
627 | 631 | ||
628 | static void nfs_zap_acl_cache(struct inode *inode) | 632 | static void nfs_zap_acl_cache(struct inode *inode) |
@@ -632,7 +636,9 @@ static void nfs_zap_acl_cache(struct inode *inode) | |||
632 | clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; | 636 | clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; |
633 | if (clear_acl_cache != NULL) | 637 | if (clear_acl_cache != NULL) |
634 | clear_acl_cache(inode); | 638 | clear_acl_cache(inode); |
635 | NFS_I(inode)->flags &= ~NFS_INO_INVALID_ACL; | 639 | spin_lock(&inode->i_lock); |
640 | NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL; | ||
641 | spin_unlock(&inode->i_lock); | ||
636 | } | 642 | } |
637 | 643 | ||
638 | /* | 644 | /* |
@@ -739,7 +745,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
739 | inode->i_fop = &nfs_dir_operations; | 745 | inode->i_fop = &nfs_dir_operations; |
740 | if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) | 746 | if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) |
741 | && fattr->size <= NFS_LIMIT_READDIRPLUS) | 747 | && fattr->size <= NFS_LIMIT_READDIRPLUS) |
742 | NFS_FLAGS(inode) |= NFS_INO_ADVISE_RDPLUS; | 748 | set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode)); |
743 | } else if (S_ISLNK(inode->i_mode)) | 749 | } else if (S_ISLNK(inode->i_mode)) |
744 | inode->i_op = &nfs_symlink_inode_operations; | 750 | inode->i_op = &nfs_symlink_inode_operations; |
745 | else | 751 | else |
@@ -814,55 +820,84 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
814 | nfs_wb_all(inode); | 820 | nfs_wb_all(inode); |
815 | } | 821 | } |
816 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 822 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); |
817 | if (error == 0) { | 823 | if (error == 0) |
818 | nfs_refresh_inode(inode, &fattr); | 824 | nfs_refresh_inode(inode, &fattr); |
825 | nfs_end_data_update(inode); | ||
826 | unlock_kernel(); | ||
827 | return error; | ||
828 | } | ||
829 | |||
830 | /** | ||
831 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. | ||
832 | * @inode: pointer to struct inode | ||
833 | * @attr: pointer to struct iattr | ||
834 | * | ||
835 | * Note: we do this in the *proc.c in order to ensure that | ||
836 | * it works for things like exclusive creates too. | ||
837 | */ | ||
838 | void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) | ||
839 | { | ||
840 | if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) { | ||
819 | if ((attr->ia_valid & ATTR_MODE) != 0) { | 841 | if ((attr->ia_valid & ATTR_MODE) != 0) { |
820 | int mode; | 842 | int mode = attr->ia_mode & S_IALLUGO; |
821 | mode = inode->i_mode & ~S_IALLUGO; | 843 | mode |= inode->i_mode & ~S_IALLUGO; |
822 | mode |= attr->ia_mode & S_IALLUGO; | ||
823 | inode->i_mode = mode; | 844 | inode->i_mode = mode; |
824 | } | 845 | } |
825 | if ((attr->ia_valid & ATTR_UID) != 0) | 846 | if ((attr->ia_valid & ATTR_UID) != 0) |
826 | inode->i_uid = attr->ia_uid; | 847 | inode->i_uid = attr->ia_uid; |
827 | if ((attr->ia_valid & ATTR_GID) != 0) | 848 | if ((attr->ia_valid & ATTR_GID) != 0) |
828 | inode->i_gid = attr->ia_gid; | 849 | inode->i_gid = attr->ia_gid; |
829 | if ((attr->ia_valid & ATTR_SIZE) != 0) { | 850 | spin_lock(&inode->i_lock); |
830 | inode->i_size = attr->ia_size; | 851 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; |
831 | vmtruncate(inode, attr->ia_size); | 852 | spin_unlock(&inode->i_lock); |
832 | } | ||
833 | } | 853 | } |
834 | if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) | 854 | if ((attr->ia_valid & ATTR_SIZE) != 0) { |
835 | NFS_FLAGS(inode) |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | 855 | inode->i_size = attr->ia_size; |
836 | nfs_end_data_update(inode); | 856 | vmtruncate(inode, attr->ia_size); |
837 | unlock_kernel(); | 857 | } |
838 | return error; | 858 | } |
859 | |||
860 | static int nfs_wait_schedule(void *word) | ||
861 | { | ||
862 | if (signal_pending(current)) | ||
863 | return -ERESTARTSYS; | ||
864 | schedule(); | ||
865 | return 0; | ||
839 | } | 866 | } |
840 | 867 | ||
841 | /* | 868 | /* |
842 | * Wait for the inode to get unlocked. | 869 | * Wait for the inode to get unlocked. |
843 | * (Used for NFS_INO_LOCKED and NFS_INO_REVALIDATING). | ||
844 | */ | 870 | */ |
845 | static int | 871 | static int nfs_wait_on_inode(struct inode *inode) |
846 | nfs_wait_on_inode(struct inode *inode, int flag) | ||
847 | { | 872 | { |
848 | struct rpc_clnt *clnt = NFS_CLIENT(inode); | 873 | struct rpc_clnt *clnt = NFS_CLIENT(inode); |
849 | struct nfs_inode *nfsi = NFS_I(inode); | 874 | struct nfs_inode *nfsi = NFS_I(inode); |
850 | 875 | sigset_t oldmask; | |
851 | int error; | 876 | int error; |
852 | if (!(NFS_FLAGS(inode) & flag)) | 877 | |
853 | return 0; | ||
854 | atomic_inc(&inode->i_count); | 878 | atomic_inc(&inode->i_count); |
855 | error = nfs_wait_event(clnt, nfsi->nfs_i_wait, | 879 | rpc_clnt_sigmask(clnt, &oldmask); |
856 | !(NFS_FLAGS(inode) & flag)); | 880 | error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING, |
881 | nfs_wait_schedule, TASK_INTERRUPTIBLE); | ||
882 | rpc_clnt_sigunmask(clnt, &oldmask); | ||
857 | iput(inode); | 883 | iput(inode); |
884 | |||
858 | return error; | 885 | return error; |
859 | } | 886 | } |
860 | 887 | ||
888 | static void nfs_wake_up_inode(struct inode *inode) | ||
889 | { | ||
890 | struct nfs_inode *nfsi = NFS_I(inode); | ||
891 | |||
892 | clear_bit(NFS_INO_REVALIDATING, &nfsi->flags); | ||
893 | smp_mb__after_clear_bit(); | ||
894 | wake_up_bit(&nfsi->flags, NFS_INO_REVALIDATING); | ||
895 | } | ||
896 | |||
861 | int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | 897 | int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) |
862 | { | 898 | { |
863 | struct inode *inode = dentry->d_inode; | 899 | struct inode *inode = dentry->d_inode; |
864 | struct nfs_inode *nfsi = NFS_I(inode); | 900 | int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; |
865 | int need_atime = nfsi->flags & NFS_INO_INVALID_ATIME; | ||
866 | int err; | 901 | int err; |
867 | 902 | ||
868 | if (__IS_FLG(inode, MS_NOATIME)) | 903 | if (__IS_FLG(inode, MS_NOATIME)) |
@@ -1008,7 +1043,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1008 | struct nfs_fattr fattr; | 1043 | struct nfs_fattr fattr; |
1009 | struct nfs_inode *nfsi = NFS_I(inode); | 1044 | struct nfs_inode *nfsi = NFS_I(inode); |
1010 | unsigned long verifier; | 1045 | unsigned long verifier; |
1011 | unsigned int flags; | 1046 | unsigned long cache_validity; |
1012 | 1047 | ||
1013 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", | 1048 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", |
1014 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); | 1049 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); |
@@ -1019,18 +1054,19 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1019 | if (NFS_STALE(inode)) | 1054 | if (NFS_STALE(inode)) |
1020 | goto out_nowait; | 1055 | goto out_nowait; |
1021 | 1056 | ||
1022 | while (NFS_REVALIDATING(inode)) { | 1057 | status = nfs_wait_on_inode(inode); |
1023 | status = nfs_wait_on_inode(inode, NFS_INO_REVALIDATING); | 1058 | if (status < 0) |
1024 | if (status < 0) | 1059 | goto out; |
1025 | goto out_nowait; | 1060 | if (NFS_STALE(inode)) { |
1026 | if (NFS_ATTRTIMEO(inode) == 0) | 1061 | status = -ESTALE; |
1027 | continue; | 1062 | /* Do we trust the cached ESTALE? */ |
1028 | if (NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) | 1063 | if (NFS_ATTRTIMEO(inode) != 0) { |
1029 | continue; | 1064 | if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) { |
1030 | status = NFS_STALE(inode) ? -ESTALE : 0; | 1065 | /* no */ |
1031 | goto out_nowait; | 1066 | } else |
1067 | goto out; | ||
1068 | } | ||
1032 | } | 1069 | } |
1033 | NFS_FLAGS(inode) |= NFS_INO_REVALIDATING; | ||
1034 | 1070 | ||
1035 | /* Protect against RPC races by saving the change attribute */ | 1071 | /* Protect against RPC races by saving the change attribute */ |
1036 | verifier = nfs_save_change_attribute(inode); | 1072 | verifier = nfs_save_change_attribute(inode); |
@@ -1042,7 +1078,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1042 | if (status == -ESTALE) { | 1078 | if (status == -ESTALE) { |
1043 | nfs_zap_caches(inode); | 1079 | nfs_zap_caches(inode); |
1044 | if (!S_ISDIR(inode->i_mode)) | 1080 | if (!S_ISDIR(inode->i_mode)) |
1045 | NFS_FLAGS(inode) |= NFS_INO_STALE; | 1081 | set_bit(NFS_INO_STALE, &NFS_FLAGS(inode)); |
1046 | } | 1082 | } |
1047 | goto out; | 1083 | goto out; |
1048 | } | 1084 | } |
@@ -1054,25 +1090,30 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1054 | (long long)NFS_FILEID(inode), status); | 1090 | (long long)NFS_FILEID(inode), status); |
1055 | goto out; | 1091 | goto out; |
1056 | } | 1092 | } |
1057 | flags = nfsi->flags; | 1093 | spin_lock(&inode->i_lock); |
1058 | nfsi->flags &= ~NFS_INO_REVAL_PAGECACHE; | 1094 | cache_validity = nfsi->cache_validity; |
1095 | nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; | ||
1096 | |||
1059 | /* | 1097 | /* |
1060 | * We may need to keep the attributes marked as invalid if | 1098 | * We may need to keep the attributes marked as invalid if |
1061 | * we raced with nfs_end_attr_update(). | 1099 | * we raced with nfs_end_attr_update(). |
1062 | */ | 1100 | */ |
1063 | if (verifier == nfsi->cache_change_attribute) | 1101 | if (verifier == nfsi->cache_change_attribute) |
1064 | nfsi->flags &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); | 1102 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); |
1065 | /* Do the page cache invalidation */ | 1103 | spin_unlock(&inode->i_lock); |
1104 | |||
1066 | nfs_revalidate_mapping(inode, inode->i_mapping); | 1105 | nfs_revalidate_mapping(inode, inode->i_mapping); |
1067 | if (flags & NFS_INO_INVALID_ACL) | 1106 | |
1107 | if (cache_validity & NFS_INO_INVALID_ACL) | ||
1068 | nfs_zap_acl_cache(inode); | 1108 | nfs_zap_acl_cache(inode); |
1109 | |||
1069 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n", | 1110 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n", |
1070 | inode->i_sb->s_id, | 1111 | inode->i_sb->s_id, |
1071 | (long long)NFS_FILEID(inode)); | 1112 | (long long)NFS_FILEID(inode)); |
1072 | 1113 | ||
1073 | out: | 1114 | out: |
1074 | NFS_FLAGS(inode) &= ~NFS_INO_REVALIDATING; | 1115 | nfs_wake_up_inode(inode); |
1075 | wake_up(&nfsi->nfs_i_wait); | 1116 | |
1076 | out_nowait: | 1117 | out_nowait: |
1077 | unlock_kernel(); | 1118 | unlock_kernel(); |
1078 | return status; | 1119 | return status; |
@@ -1096,7 +1137,7 @@ int nfs_attribute_timeout(struct inode *inode) | |||
1096 | */ | 1137 | */ |
1097 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 1138 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
1098 | { | 1139 | { |
1099 | if (!(NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) | 1140 | if (!(NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) |
1100 | && !nfs_attribute_timeout(inode)) | 1141 | && !nfs_attribute_timeout(inode)) |
1101 | return NFS_STALE(inode) ? -ESTALE : 0; | 1142 | return NFS_STALE(inode) ? -ESTALE : 0; |
1102 | return __nfs_revalidate_inode(server, inode); | 1143 | return __nfs_revalidate_inode(server, inode); |
@@ -1111,19 +1152,23 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) | |||
1111 | { | 1152 | { |
1112 | struct nfs_inode *nfsi = NFS_I(inode); | 1153 | struct nfs_inode *nfsi = NFS_I(inode); |
1113 | 1154 | ||
1114 | if (nfsi->flags & NFS_INO_INVALID_DATA) { | 1155 | if (nfsi->cache_validity & NFS_INO_INVALID_DATA) { |
1115 | if (S_ISREG(inode->i_mode)) { | 1156 | if (S_ISREG(inode->i_mode)) { |
1116 | if (filemap_fdatawrite(mapping) == 0) | 1157 | if (filemap_fdatawrite(mapping) == 0) |
1117 | filemap_fdatawait(mapping); | 1158 | filemap_fdatawait(mapping); |
1118 | nfs_wb_all(inode); | 1159 | nfs_wb_all(inode); |
1119 | } | 1160 | } |
1120 | invalidate_inode_pages2(mapping); | 1161 | invalidate_inode_pages2(mapping); |
1121 | nfsi->flags &= ~NFS_INO_INVALID_DATA; | 1162 | |
1163 | spin_lock(&inode->i_lock); | ||
1164 | nfsi->cache_validity &= ~NFS_INO_INVALID_DATA; | ||
1122 | if (S_ISDIR(inode->i_mode)) { | 1165 | if (S_ISDIR(inode->i_mode)) { |
1123 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); | 1166 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); |
1124 | /* This ensures we revalidate child dentries */ | 1167 | /* This ensures we revalidate child dentries */ |
1125 | nfsi->cache_change_attribute++; | 1168 | nfsi->cache_change_attribute++; |
1126 | } | 1169 | } |
1170 | spin_unlock(&inode->i_lock); | ||
1171 | |||
1127 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", | 1172 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", |
1128 | inode->i_sb->s_id, | 1173 | inode->i_sb->s_id, |
1129 | (long long)NFS_FILEID(inode)); | 1174 | (long long)NFS_FILEID(inode)); |
@@ -1153,10 +1198,12 @@ void nfs_end_data_update(struct inode *inode) | |||
1153 | 1198 | ||
1154 | if (!nfs_have_delegation(inode, FMODE_READ)) { | 1199 | if (!nfs_have_delegation(inode, FMODE_READ)) { |
1155 | /* Mark the attribute cache for revalidation */ | 1200 | /* Mark the attribute cache for revalidation */ |
1156 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1201 | spin_lock(&inode->i_lock); |
1202 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | ||
1157 | /* Directories and symlinks: invalidate page cache too */ | 1203 | /* Directories and symlinks: invalidate page cache too */ |
1158 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) | 1204 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) |
1159 | nfsi->flags |= NFS_INO_INVALID_DATA; | 1205 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
1206 | spin_unlock(&inode->i_lock); | ||
1160 | } | 1207 | } |
1161 | nfsi->cache_change_attribute ++; | 1208 | nfsi->cache_change_attribute ++; |
1162 | atomic_dec(&nfsi->data_updates); | 1209 | atomic_dec(&nfsi->data_updates); |
@@ -1181,6 +1228,8 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1181 | if (nfs_have_delegation(inode, FMODE_READ)) | 1228 | if (nfs_have_delegation(inode, FMODE_READ)) |
1182 | return 0; | 1229 | return 0; |
1183 | 1230 | ||
1231 | spin_lock(&inode->i_lock); | ||
1232 | |||
1184 | /* Are we in the process of updating data on the server? */ | 1233 | /* Are we in the process of updating data on the server? */ |
1185 | data_unstable = nfs_caches_unstable(inode); | 1234 | data_unstable = nfs_caches_unstable(inode); |
1186 | 1235 | ||
@@ -1189,19 +1238,23 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1189 | && nfsi->change_attr == fattr->pre_change_attr) | 1238 | && nfsi->change_attr == fattr->pre_change_attr) |
1190 | nfsi->change_attr = fattr->change_attr; | 1239 | nfsi->change_attr = fattr->change_attr; |
1191 | if (nfsi->change_attr != fattr->change_attr) { | 1240 | if (nfsi->change_attr != fattr->change_attr) { |
1192 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1241 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1193 | if (!data_unstable) | 1242 | if (!data_unstable) |
1194 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | 1243 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
1195 | } | 1244 | } |
1196 | } | 1245 | } |
1197 | 1246 | ||
1198 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) | 1247 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) { |
1248 | spin_unlock(&inode->i_lock); | ||
1199 | return 0; | 1249 | return 0; |
1250 | } | ||
1200 | 1251 | ||
1201 | /* Has the inode gone and changed behind our back? */ | 1252 | /* Has the inode gone and changed behind our back? */ |
1202 | if (nfsi->fileid != fattr->fileid | 1253 | if (nfsi->fileid != fattr->fileid |
1203 | || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) | 1254 | || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) { |
1255 | spin_unlock(&inode->i_lock); | ||
1204 | return -EIO; | 1256 | return -EIO; |
1257 | } | ||
1205 | 1258 | ||
1206 | cur_size = i_size_read(inode); | 1259 | cur_size = i_size_read(inode); |
1207 | new_isize = nfs_size_to_loff_t(fattr->size); | 1260 | new_isize = nfs_size_to_loff_t(fattr->size); |
@@ -1216,30 +1269,31 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1216 | 1269 | ||
1217 | /* Verify a few of the more important attributes */ | 1270 | /* Verify a few of the more important attributes */ |
1218 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { | 1271 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { |
1219 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1272 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1220 | if (!data_unstable) | 1273 | if (!data_unstable) |
1221 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | 1274 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
1222 | } | 1275 | } |
1223 | if (cur_size != new_isize) { | 1276 | if (cur_size != new_isize) { |
1224 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1277 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1225 | if (nfsi->npages == 0) | 1278 | if (nfsi->npages == 0) |
1226 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | 1279 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
1227 | } | 1280 | } |
1228 | 1281 | ||
1229 | /* Have any file permissions changed? */ | 1282 | /* Have any file permissions changed? */ |
1230 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) | 1283 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) |
1231 | || inode->i_uid != fattr->uid | 1284 | || inode->i_uid != fattr->uid |
1232 | || inode->i_gid != fattr->gid) | 1285 | || inode->i_gid != fattr->gid) |
1233 | nfsi->flags |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; | 1286 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; |
1234 | 1287 | ||
1235 | /* Has the link count changed? */ | 1288 | /* Has the link count changed? */ |
1236 | if (inode->i_nlink != fattr->nlink) | 1289 | if (inode->i_nlink != fattr->nlink) |
1237 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1290 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1238 | 1291 | ||
1239 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) | 1292 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) |
1240 | nfsi->flags |= NFS_INO_INVALID_ATIME; | 1293 | nfsi->cache_validity |= NFS_INO_INVALID_ATIME; |
1241 | 1294 | ||
1242 | nfsi->read_cache_jiffies = fattr->timestamp; | 1295 | nfsi->read_cache_jiffies = fattr->timestamp; |
1296 | spin_unlock(&inode->i_lock); | ||
1243 | return 0; | 1297 | return 0; |
1244 | } | 1298 | } |
1245 | 1299 | ||
@@ -1278,11 +1332,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign | |||
1278 | goto out_err; | 1332 | goto out_err; |
1279 | } | 1333 | } |
1280 | 1334 | ||
1335 | spin_lock(&inode->i_lock); | ||
1336 | |||
1281 | /* | 1337 | /* |
1282 | * Make sure the inode's type hasn't changed. | 1338 | * Make sure the inode's type hasn't changed. |
1283 | */ | 1339 | */ |
1284 | if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) | 1340 | if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) { |
1341 | spin_unlock(&inode->i_lock); | ||
1285 | goto out_changed; | 1342 | goto out_changed; |
1343 | } | ||
1286 | 1344 | ||
1287 | /* | 1345 | /* |
1288 | * Update the read time so we don't revalidate too often. | 1346 | * Update the read time so we don't revalidate too often. |
@@ -1373,8 +1431,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign | |||
1373 | || S_ISLNK(inode->i_mode))) | 1431 | || S_ISLNK(inode->i_mode))) |
1374 | invalid &= ~NFS_INO_INVALID_DATA; | 1432 | invalid &= ~NFS_INO_INVALID_DATA; |
1375 | if (!nfs_have_delegation(inode, FMODE_READ)) | 1433 | if (!nfs_have_delegation(inode, FMODE_READ)) |
1376 | nfsi->flags |= invalid; | 1434 | nfsi->cache_validity |= invalid; |
1377 | 1435 | ||
1436 | spin_unlock(&inode->i_lock); | ||
1378 | return 0; | 1437 | return 0; |
1379 | out_changed: | 1438 | out_changed: |
1380 | /* | 1439 | /* |
@@ -1391,7 +1450,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign | |||
1391 | */ | 1450 | */ |
1392 | nfs_invalidate_inode(inode); | 1451 | nfs_invalidate_inode(inode); |
1393 | out_err: | 1452 | out_err: |
1394 | NFS_FLAGS(inode) |= NFS_INO_STALE; | 1453 | set_bit(NFS_INO_STALE, &NFS_FLAGS(inode)); |
1395 | return -ESTALE; | 1454 | return -ESTALE; |
1396 | } | 1455 | } |
1397 | 1456 | ||
@@ -1950,7 +2009,8 @@ static struct inode *nfs_alloc_inode(struct super_block *sb) | |||
1950 | nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); | 2009 | nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); |
1951 | if (!nfsi) | 2010 | if (!nfsi) |
1952 | return NULL; | 2011 | return NULL; |
1953 | nfsi->flags = 0; | 2012 | nfsi->flags = 0UL; |
2013 | nfsi->cache_validity = 0UL; | ||
1954 | #ifdef CONFIG_NFS_V3_ACL | 2014 | #ifdef CONFIG_NFS_V3_ACL |
1955 | nfsi->acl_access = ERR_PTR(-EAGAIN); | 2015 | nfsi->acl_access = ERR_PTR(-EAGAIN); |
1956 | nfsi->acl_default = ERR_PTR(-EAGAIN); | 2016 | nfsi->acl_default = ERR_PTR(-EAGAIN); |
@@ -1982,7 +2042,6 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) | |||
1982 | nfsi->ndirty = 0; | 2042 | nfsi->ndirty = 0; |
1983 | nfsi->ncommit = 0; | 2043 | nfsi->ncommit = 0; |
1984 | nfsi->npages = 0; | 2044 | nfsi->npages = 0; |
1985 | init_waitqueue_head(&nfsi->nfs_i_wait); | ||
1986 | nfs4_init_once(nfsi); | 2045 | nfs4_init_once(nfsi); |
1987 | } | 2046 | } |
1988 | } | 2047 | } |