aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/dir.c28
-rw-r--r--fs/nfs/file.c5
-rw-r--r--fs/nfs/inode.c199
-rw-r--r--fs/nfs/nfs3acl.c4
-rw-r--r--fs/nfs/nfs3proc.c7
-rw-r--r--fs/nfs/nfs4proc.c22
-rw-r--r--fs/nfs/proc.c2
-rw-r--r--fs/nfs/read.c8
-rw-r--r--fs/nfs/symlink.c37
9 files changed, 188 insertions, 124 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index b38a57e78a63..2df639f143e8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -182,14 +182,16 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
182 /* We requested READDIRPLUS, but the server doesn't grok it */ 182 /* We requested READDIRPLUS, but the server doesn't grok it */
183 if (error == -ENOTSUPP && desc->plus) { 183 if (error == -ENOTSUPP && desc->plus) {
184 NFS_SERVER(inode)->caps &= ~NFS_CAP_READDIRPLUS; 184 NFS_SERVER(inode)->caps &= ~NFS_CAP_READDIRPLUS;
185 NFS_FLAGS(inode) &= ~NFS_INO_ADVISE_RDPLUS; 185 clear_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
186 desc->plus = 0; 186 desc->plus = 0;
187 goto again; 187 goto again;
188 } 188 }
189 goto error; 189 goto error;
190 } 190 }
191 SetPageUptodate(page); 191 SetPageUptodate(page);
192 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME; 192 spin_lock(&inode->i_lock);
193 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
194 spin_unlock(&inode->i_lock);
193 /* Ensure consistent page alignment of the data. 195 /* Ensure consistent page alignment of the data.
194 * Note: assumes we have exclusive access to this mapping either 196 * Note: assumes we have exclusive access to this mapping either
195 * through inode->i_sem or some other mechanism. 197 * through inode->i_sem or some other mechanism.
@@ -462,7 +464,9 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
462 page, 464 page,
463 NFS_SERVER(inode)->dtsize, 465 NFS_SERVER(inode)->dtsize,
464 desc->plus); 466 desc->plus);
465 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME; 467 spin_lock(&inode->i_lock);
468 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
469 spin_unlock(&inode->i_lock);
466 desc->page = page; 470 desc->page = page;
467 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ 471 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */
468 if (desc->error >= 0) { 472 if (desc->error >= 0) {
@@ -545,7 +549,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
545 break; 549 break;
546 } 550 }
547 if (res == -ETOOSMALL && desc->plus) { 551 if (res == -ETOOSMALL && desc->plus) {
548 NFS_FLAGS(inode) &= ~NFS_INO_ADVISE_RDPLUS; 552 clear_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
549 nfs_zap_caches(inode); 553 nfs_zap_caches(inode);
550 desc->plus = 0; 554 desc->plus = 0;
551 desc->entry->eof = 0; 555 desc->entry->eof = 0;
@@ -608,7 +612,7 @@ static inline int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
608{ 612{
609 if (IS_ROOT(dentry)) 613 if (IS_ROOT(dentry))
610 return 1; 614 return 1;
611 if ((NFS_FLAGS(dir) & NFS_INO_INVALID_ATTR) != 0 615 if ((NFS_I(dir)->cache_validity & NFS_INO_INVALID_ATTR) != 0
612 || nfs_attribute_timeout(dir)) 616 || nfs_attribute_timeout(dir))
613 return 0; 617 return 0;
614 return nfs_verify_change_attribute(dir, (unsigned long)dentry->d_fsdata); 618 return nfs_verify_change_attribute(dir, (unsigned long)dentry->d_fsdata);
@@ -935,6 +939,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
935 error = nfs_revalidate_inode(NFS_SERVER(dir), dir); 939 error = nfs_revalidate_inode(NFS_SERVER(dir), dir);
936 if (error < 0) { 940 if (error < 0) {
937 res = ERR_PTR(error); 941 res = ERR_PTR(error);
942 unlock_kernel();
938 goto out; 943 goto out;
939 } 944 }
940 945
@@ -1575,11 +1580,12 @@ out:
1575 1580
1576int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) 1581int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res)
1577{ 1582{
1578 struct nfs_access_entry *cache = &NFS_I(inode)->cache_access; 1583 struct nfs_inode *nfsi = NFS_I(inode);
1584 struct nfs_access_entry *cache = &nfsi->cache_access;
1579 1585
1580 if (cache->cred != cred 1586 if (cache->cred != cred
1581 || time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode)) 1587 || time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode))
1582 || (NFS_FLAGS(inode) & NFS_INO_INVALID_ACCESS)) 1588 || (nfsi->cache_validity & NFS_INO_INVALID_ACCESS))
1583 return -ENOENT; 1589 return -ENOENT;
1584 memcpy(res, cache, sizeof(*res)); 1590 memcpy(res, cache, sizeof(*res));
1585 return 0; 1591 return 0;
@@ -1587,14 +1593,18 @@ int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs
1587 1593
1588void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) 1594void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
1589{ 1595{
1590 struct nfs_access_entry *cache = &NFS_I(inode)->cache_access; 1596 struct nfs_inode *nfsi = NFS_I(inode);
1597 struct nfs_access_entry *cache = &nfsi->cache_access;
1591 1598
1592 if (cache->cred != set->cred) { 1599 if (cache->cred != set->cred) {
1593 if (cache->cred) 1600 if (cache->cred)
1594 put_rpccred(cache->cred); 1601 put_rpccred(cache->cred);
1595 cache->cred = get_rpccred(set->cred); 1602 cache->cred = get_rpccred(set->cred);
1596 } 1603 }
1597 NFS_FLAGS(inode) &= ~NFS_INO_INVALID_ACCESS; 1604 /* FIXME: replace current access_cache BKL reliance with inode->i_lock */
1605 spin_lock(&inode->i_lock);
1606 nfsi->cache_validity &= ~NFS_INO_INVALID_ACCESS;
1607 spin_unlock(&inode->i_lock);
1598 cache->jiffies = set->jiffies; 1608 cache->jiffies = set->jiffies;
1599 cache->mask = set->mask; 1609 cache->mask = set->mask;
1600} 1610}
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 5621ba9885f4..f6b9eda925c5 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -134,9 +134,10 @@ nfs_file_release(struct inode *inode, struct file *filp)
134 */ 134 */
135static int nfs_revalidate_file(struct inode *inode, struct file *filp) 135static int nfs_revalidate_file(struct inode *inode, struct file *filp)
136{ 136{
137 struct nfs_inode *nfsi = NFS_I(inode);
137 int retval = 0; 138 int retval = 0;
138 139
139 if ((NFS_FLAGS(inode) & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode)) 140 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode))
140 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 141 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
141 nfs_revalidate_mapping(inode, filp->f_mapping); 142 nfs_revalidate_mapping(inode, filp->f_mapping);
142 return 0; 143 return 0;
@@ -164,7 +165,7 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
164 goto force_reval; 165 goto force_reval;
165 if (nfsi->npages != 0) 166 if (nfsi->npages != 0)
166 return 0; 167 return 0;
167 if (!(NFS_FLAGS(inode) & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode)) 168 if (!(nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) && !nfs_attribute_timeout(inode))
168 return 0; 169 return 0;
169force_reval: 170force_reval:
170 return __nfs_revalidate_inode(server, inode); 171 return __nfs_revalidate_inode(server, inode);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 4845911f1c63..6922469d6fc5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -146,6 +146,8 @@ nfs_delete_inode(struct inode * inode)
146{ 146{
147 dprintk("NFS: delete_inode(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); 147 dprintk("NFS: delete_inode(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino);
148 148
149 truncate_inode_pages(&inode->i_data, 0);
150
149 nfs_wb_all(inode); 151 nfs_wb_all(inode);
150 /* 152 /*
151 * The following should never happen... 153 * The following should never happen...
@@ -615,14 +617,18 @@ nfs_zap_caches(struct inode *inode)
615 struct nfs_inode *nfsi = NFS_I(inode); 617 struct nfs_inode *nfsi = NFS_I(inode);
616 int mode = inode->i_mode; 618 int mode = inode->i_mode;
617 619
620 spin_lock(&inode->i_lock);
621
618 NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); 622 NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
619 NFS_ATTRTIMEO_UPDATE(inode) = jiffies; 623 NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
620 624
621 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); 625 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
622 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) 626 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; 627 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 628 else
625 nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; 629 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
630
631 spin_unlock(&inode->i_lock);
626} 632}
627 633
628static void nfs_zap_acl_cache(struct inode *inode) 634static void nfs_zap_acl_cache(struct inode *inode)
@@ -632,7 +638,9 @@ static void nfs_zap_acl_cache(struct inode *inode)
632 clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; 638 clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache;
633 if (clear_acl_cache != NULL) 639 if (clear_acl_cache != NULL)
634 clear_acl_cache(inode); 640 clear_acl_cache(inode);
635 NFS_I(inode)->flags &= ~NFS_INO_INVALID_ACL; 641 spin_lock(&inode->i_lock);
642 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL;
643 spin_unlock(&inode->i_lock);
636} 644}
637 645
638/* 646/*
@@ -739,7 +747,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
739 inode->i_fop = &nfs_dir_operations; 747 inode->i_fop = &nfs_dir_operations;
740 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) 748 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS)
741 && fattr->size <= NFS_LIMIT_READDIRPLUS) 749 && fattr->size <= NFS_LIMIT_READDIRPLUS)
742 NFS_FLAGS(inode) |= NFS_INO_ADVISE_RDPLUS; 750 set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
743 } else if (S_ISLNK(inode->i_mode)) 751 } else if (S_ISLNK(inode->i_mode))
744 inode->i_op = &nfs_symlink_inode_operations; 752 inode->i_op = &nfs_symlink_inode_operations;
745 else 753 else
@@ -814,55 +822,84 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
814 nfs_wb_all(inode); 822 nfs_wb_all(inode);
815 } 823 }
816 error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); 824 error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
817 if (error == 0) { 825 if (error == 0)
818 nfs_refresh_inode(inode, &fattr); 826 nfs_refresh_inode(inode, &fattr);
827 nfs_end_data_update(inode);
828 unlock_kernel();
829 return error;
830}
831
832/**
833 * nfs_setattr_update_inode - Update inode metadata after a setattr call.
834 * @inode: pointer to struct inode
835 * @attr: pointer to struct iattr
836 *
837 * Note: we do this in the *proc.c in order to ensure that
838 * it works for things like exclusive creates too.
839 */
840void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
841{
842 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) {
819 if ((attr->ia_valid & ATTR_MODE) != 0) { 843 if ((attr->ia_valid & ATTR_MODE) != 0) {
820 int mode; 844 int mode = attr->ia_mode & S_IALLUGO;
821 mode = inode->i_mode & ~S_IALLUGO; 845 mode |= inode->i_mode & ~S_IALLUGO;
822 mode |= attr->ia_mode & S_IALLUGO;
823 inode->i_mode = mode; 846 inode->i_mode = mode;
824 } 847 }
825 if ((attr->ia_valid & ATTR_UID) != 0) 848 if ((attr->ia_valid & ATTR_UID) != 0)
826 inode->i_uid = attr->ia_uid; 849 inode->i_uid = attr->ia_uid;
827 if ((attr->ia_valid & ATTR_GID) != 0) 850 if ((attr->ia_valid & ATTR_GID) != 0)
828 inode->i_gid = attr->ia_gid; 851 inode->i_gid = attr->ia_gid;
829 if ((attr->ia_valid & ATTR_SIZE) != 0) { 852 spin_lock(&inode->i_lock);
830 inode->i_size = attr->ia_size; 853 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
831 vmtruncate(inode, attr->ia_size); 854 spin_unlock(&inode->i_lock);
832 } 855 }
856 if ((attr->ia_valid & ATTR_SIZE) != 0) {
857 inode->i_size = attr->ia_size;
858 vmtruncate(inode, attr->ia_size);
833 } 859 }
834 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) 860}
835 NFS_FLAGS(inode) |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; 861
836 nfs_end_data_update(inode); 862static int nfs_wait_schedule(void *word)
837 unlock_kernel(); 863{
838 return error; 864 if (signal_pending(current))
865 return -ERESTARTSYS;
866 schedule();
867 return 0;
839} 868}
840 869
841/* 870/*
842 * Wait for the inode to get unlocked. 871 * Wait for the inode to get unlocked.
843 * (Used for NFS_INO_LOCKED and NFS_INO_REVALIDATING).
844 */ 872 */
845static int 873static int nfs_wait_on_inode(struct inode *inode)
846nfs_wait_on_inode(struct inode *inode, int flag)
847{ 874{
848 struct rpc_clnt *clnt = NFS_CLIENT(inode); 875 struct rpc_clnt *clnt = NFS_CLIENT(inode);
849 struct nfs_inode *nfsi = NFS_I(inode); 876 struct nfs_inode *nfsi = NFS_I(inode);
850 877 sigset_t oldmask;
851 int error; 878 int error;
852 if (!(NFS_FLAGS(inode) & flag)) 879
853 return 0;
854 atomic_inc(&inode->i_count); 880 atomic_inc(&inode->i_count);
855 error = nfs_wait_event(clnt, nfsi->nfs_i_wait, 881 rpc_clnt_sigmask(clnt, &oldmask);
856 !(NFS_FLAGS(inode) & flag)); 882 error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING,
883 nfs_wait_schedule, TASK_INTERRUPTIBLE);
884 rpc_clnt_sigunmask(clnt, &oldmask);
857 iput(inode); 885 iput(inode);
886
858 return error; 887 return error;
859} 888}
860 889
890static void nfs_wake_up_inode(struct inode *inode)
891{
892 struct nfs_inode *nfsi = NFS_I(inode);
893
894 clear_bit(NFS_INO_REVALIDATING, &nfsi->flags);
895 smp_mb__after_clear_bit();
896 wake_up_bit(&nfsi->flags, NFS_INO_REVALIDATING);
897}
898
861int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) 899int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
862{ 900{
863 struct inode *inode = dentry->d_inode; 901 struct inode *inode = dentry->d_inode;
864 struct nfs_inode *nfsi = NFS_I(inode); 902 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; 903 int err;
867 904
868 if (__IS_FLG(inode, MS_NOATIME)) 905 if (__IS_FLG(inode, MS_NOATIME))
@@ -1008,7 +1045,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1008 struct nfs_fattr fattr; 1045 struct nfs_fattr fattr;
1009 struct nfs_inode *nfsi = NFS_I(inode); 1046 struct nfs_inode *nfsi = NFS_I(inode);
1010 unsigned long verifier; 1047 unsigned long verifier;
1011 unsigned int flags; 1048 unsigned long cache_validity;
1012 1049
1013 dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", 1050 dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n",
1014 inode->i_sb->s_id, (long long)NFS_FILEID(inode)); 1051 inode->i_sb->s_id, (long long)NFS_FILEID(inode));
@@ -1019,18 +1056,19 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1019 if (NFS_STALE(inode)) 1056 if (NFS_STALE(inode))
1020 goto out_nowait; 1057 goto out_nowait;
1021 1058
1022 while (NFS_REVALIDATING(inode)) { 1059 status = nfs_wait_on_inode(inode);
1023 status = nfs_wait_on_inode(inode, NFS_INO_REVALIDATING); 1060 if (status < 0)
1024 if (status < 0) 1061 goto out;
1025 goto out_nowait; 1062 if (NFS_STALE(inode)) {
1026 if (NFS_ATTRTIMEO(inode) == 0) 1063 status = -ESTALE;
1027 continue; 1064 /* Do we trust the cached ESTALE? */
1028 if (NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) 1065 if (NFS_ATTRTIMEO(inode) != 0) {
1029 continue; 1066 if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) {
1030 status = NFS_STALE(inode) ? -ESTALE : 0; 1067 /* no */
1031 goto out_nowait; 1068 } else
1069 goto out;
1070 }
1032 } 1071 }
1033 NFS_FLAGS(inode) |= NFS_INO_REVALIDATING;
1034 1072
1035 /* Protect against RPC races by saving the change attribute */ 1073 /* Protect against RPC races by saving the change attribute */
1036 verifier = nfs_save_change_attribute(inode); 1074 verifier = nfs_save_change_attribute(inode);
@@ -1042,7 +1080,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1042 if (status == -ESTALE) { 1080 if (status == -ESTALE) {
1043 nfs_zap_caches(inode); 1081 nfs_zap_caches(inode);
1044 if (!S_ISDIR(inode->i_mode)) 1082 if (!S_ISDIR(inode->i_mode))
1045 NFS_FLAGS(inode) |= NFS_INO_STALE; 1083 set_bit(NFS_INO_STALE, &NFS_FLAGS(inode));
1046 } 1084 }
1047 goto out; 1085 goto out;
1048 } 1086 }
@@ -1054,25 +1092,30 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1054 (long long)NFS_FILEID(inode), status); 1092 (long long)NFS_FILEID(inode), status);
1055 goto out; 1093 goto out;
1056 } 1094 }
1057 flags = nfsi->flags; 1095 spin_lock(&inode->i_lock);
1058 nfsi->flags &= ~NFS_INO_REVAL_PAGECACHE; 1096 cache_validity = nfsi->cache_validity;
1097 nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
1098
1059 /* 1099 /*
1060 * We may need to keep the attributes marked as invalid if 1100 * We may need to keep the attributes marked as invalid if
1061 * we raced with nfs_end_attr_update(). 1101 * we raced with nfs_end_attr_update().
1062 */ 1102 */
1063 if (verifier == nfsi->cache_change_attribute) 1103 if (verifier == nfsi->cache_change_attribute)
1064 nfsi->flags &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); 1104 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME);
1065 /* Do the page cache invalidation */ 1105 spin_unlock(&inode->i_lock);
1106
1066 nfs_revalidate_mapping(inode, inode->i_mapping); 1107 nfs_revalidate_mapping(inode, inode->i_mapping);
1067 if (flags & NFS_INO_INVALID_ACL) 1108
1109 if (cache_validity & NFS_INO_INVALID_ACL)
1068 nfs_zap_acl_cache(inode); 1110 nfs_zap_acl_cache(inode);
1111
1069 dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n", 1112 dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n",
1070 inode->i_sb->s_id, 1113 inode->i_sb->s_id,
1071 (long long)NFS_FILEID(inode)); 1114 (long long)NFS_FILEID(inode));
1072 1115
1073out: 1116 out:
1074 NFS_FLAGS(inode) &= ~NFS_INO_REVALIDATING; 1117 nfs_wake_up_inode(inode);
1075 wake_up(&nfsi->nfs_i_wait); 1118
1076 out_nowait: 1119 out_nowait:
1077 unlock_kernel(); 1120 unlock_kernel();
1078 return status; 1121 return status;
@@ -1096,7 +1139,7 @@ int nfs_attribute_timeout(struct inode *inode)
1096 */ 1139 */
1097int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) 1140int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1098{ 1141{
1099 if (!(NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) 1142 if (!(NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA))
1100 && !nfs_attribute_timeout(inode)) 1143 && !nfs_attribute_timeout(inode))
1101 return NFS_STALE(inode) ? -ESTALE : 0; 1144 return NFS_STALE(inode) ? -ESTALE : 0;
1102 return __nfs_revalidate_inode(server, inode); 1145 return __nfs_revalidate_inode(server, inode);
@@ -1111,19 +1154,23 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
1111{ 1154{
1112 struct nfs_inode *nfsi = NFS_I(inode); 1155 struct nfs_inode *nfsi = NFS_I(inode);
1113 1156
1114 if (nfsi->flags & NFS_INO_INVALID_DATA) { 1157 if (nfsi->cache_validity & NFS_INO_INVALID_DATA) {
1115 if (S_ISREG(inode->i_mode)) { 1158 if (S_ISREG(inode->i_mode)) {
1116 if (filemap_fdatawrite(mapping) == 0) 1159 if (filemap_fdatawrite(mapping) == 0)
1117 filemap_fdatawait(mapping); 1160 filemap_fdatawait(mapping);
1118 nfs_wb_all(inode); 1161 nfs_wb_all(inode);
1119 } 1162 }
1120 invalidate_inode_pages2(mapping); 1163 invalidate_inode_pages2(mapping);
1121 nfsi->flags &= ~NFS_INO_INVALID_DATA; 1164
1165 spin_lock(&inode->i_lock);
1166 nfsi->cache_validity &= ~NFS_INO_INVALID_DATA;
1122 if (S_ISDIR(inode->i_mode)) { 1167 if (S_ISDIR(inode->i_mode)) {
1123 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); 1168 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
1124 /* This ensures we revalidate child dentries */ 1169 /* This ensures we revalidate child dentries */
1125 nfsi->cache_change_attribute++; 1170 nfsi->cache_change_attribute++;
1126 } 1171 }
1172 spin_unlock(&inode->i_lock);
1173
1127 dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", 1174 dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n",
1128 inode->i_sb->s_id, 1175 inode->i_sb->s_id,
1129 (long long)NFS_FILEID(inode)); 1176 (long long)NFS_FILEID(inode));
@@ -1153,10 +1200,12 @@ void nfs_end_data_update(struct inode *inode)
1153 1200
1154 if (!nfs_have_delegation(inode, FMODE_READ)) { 1201 if (!nfs_have_delegation(inode, FMODE_READ)) {
1155 /* Mark the attribute cache for revalidation */ 1202 /* Mark the attribute cache for revalidation */
1156 nfsi->flags |= NFS_INO_INVALID_ATTR; 1203 spin_lock(&inode->i_lock);
1204 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1157 /* Directories and symlinks: invalidate page cache too */ 1205 /* Directories and symlinks: invalidate page cache too */
1158 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) 1206 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
1159 nfsi->flags |= NFS_INO_INVALID_DATA; 1207 nfsi->cache_validity |= NFS_INO_INVALID_DATA;
1208 spin_unlock(&inode->i_lock);
1160 } 1209 }
1161 nfsi->cache_change_attribute ++; 1210 nfsi->cache_change_attribute ++;
1162 atomic_dec(&nfsi->data_updates); 1211 atomic_dec(&nfsi->data_updates);
@@ -1181,6 +1230,8 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1181 if (nfs_have_delegation(inode, FMODE_READ)) 1230 if (nfs_have_delegation(inode, FMODE_READ))
1182 return 0; 1231 return 0;
1183 1232
1233 spin_lock(&inode->i_lock);
1234
1184 /* Are we in the process of updating data on the server? */ 1235 /* Are we in the process of updating data on the server? */
1185 data_unstable = nfs_caches_unstable(inode); 1236 data_unstable = nfs_caches_unstable(inode);
1186 1237
@@ -1189,19 +1240,23 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1189 && nfsi->change_attr == fattr->pre_change_attr) 1240 && nfsi->change_attr == fattr->pre_change_attr)
1190 nfsi->change_attr = fattr->change_attr; 1241 nfsi->change_attr = fattr->change_attr;
1191 if (nfsi->change_attr != fattr->change_attr) { 1242 if (nfsi->change_attr != fattr->change_attr) {
1192 nfsi->flags |= NFS_INO_INVALID_ATTR; 1243 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1193 if (!data_unstable) 1244 if (!data_unstable)
1194 nfsi->flags |= NFS_INO_REVAL_PAGECACHE; 1245 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1195 } 1246 }
1196 } 1247 }
1197 1248
1198 if ((fattr->valid & NFS_ATTR_FATTR) == 0) 1249 if ((fattr->valid & NFS_ATTR_FATTR) == 0) {
1250 spin_unlock(&inode->i_lock);
1199 return 0; 1251 return 0;
1252 }
1200 1253
1201 /* Has the inode gone and changed behind our back? */ 1254 /* Has the inode gone and changed behind our back? */
1202 if (nfsi->fileid != fattr->fileid 1255 if (nfsi->fileid != fattr->fileid
1203 || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) 1256 || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) {
1257 spin_unlock(&inode->i_lock);
1204 return -EIO; 1258 return -EIO;
1259 }
1205 1260
1206 cur_size = i_size_read(inode); 1261 cur_size = i_size_read(inode);
1207 new_isize = nfs_size_to_loff_t(fattr->size); 1262 new_isize = nfs_size_to_loff_t(fattr->size);
@@ -1216,30 +1271,31 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1216 1271
1217 /* Verify a few of the more important attributes */ 1272 /* Verify a few of the more important attributes */
1218 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { 1273 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) {
1219 nfsi->flags |= NFS_INO_INVALID_ATTR; 1274 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1220 if (!data_unstable) 1275 if (!data_unstable)
1221 nfsi->flags |= NFS_INO_REVAL_PAGECACHE; 1276 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1222 } 1277 }
1223 if (cur_size != new_isize) { 1278 if (cur_size != new_isize) {
1224 nfsi->flags |= NFS_INO_INVALID_ATTR; 1279 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1225 if (nfsi->npages == 0) 1280 if (nfsi->npages == 0)
1226 nfsi->flags |= NFS_INO_REVAL_PAGECACHE; 1281 nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1227 } 1282 }
1228 1283
1229 /* Have any file permissions changed? */ 1284 /* Have any file permissions changed? */
1230 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) 1285 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
1231 || inode->i_uid != fattr->uid 1286 || inode->i_uid != fattr->uid
1232 || inode->i_gid != fattr->gid) 1287 || inode->i_gid != fattr->gid)
1233 nfsi->flags |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; 1288 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
1234 1289
1235 /* Has the link count changed? */ 1290 /* Has the link count changed? */
1236 if (inode->i_nlink != fattr->nlink) 1291 if (inode->i_nlink != fattr->nlink)
1237 nfsi->flags |= NFS_INO_INVALID_ATTR; 1292 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
1238 1293
1239 if (!timespec_equal(&inode->i_atime, &fattr->atime)) 1294 if (!timespec_equal(&inode->i_atime, &fattr->atime))
1240 nfsi->flags |= NFS_INO_INVALID_ATIME; 1295 nfsi->cache_validity |= NFS_INO_INVALID_ATIME;
1241 1296
1242 nfsi->read_cache_jiffies = fattr->timestamp; 1297 nfsi->read_cache_jiffies = fattr->timestamp;
1298 spin_unlock(&inode->i_lock);
1243 return 0; 1299 return 0;
1244} 1300}
1245 1301
@@ -1278,11 +1334,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1278 goto out_err; 1334 goto out_err;
1279 } 1335 }
1280 1336
1337 spin_lock(&inode->i_lock);
1338
1281 /* 1339 /*
1282 * Make sure the inode's type hasn't changed. 1340 * Make sure the inode's type hasn't changed.
1283 */ 1341 */
1284 if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) 1342 if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) {
1343 spin_unlock(&inode->i_lock);
1285 goto out_changed; 1344 goto out_changed;
1345 }
1286 1346
1287 /* 1347 /*
1288 * Update the read time so we don't revalidate too often. 1348 * Update the read time so we don't revalidate too often.
@@ -1373,8 +1433,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1373 || S_ISLNK(inode->i_mode))) 1433 || S_ISLNK(inode->i_mode)))
1374 invalid &= ~NFS_INO_INVALID_DATA; 1434 invalid &= ~NFS_INO_INVALID_DATA;
1375 if (!nfs_have_delegation(inode, FMODE_READ)) 1435 if (!nfs_have_delegation(inode, FMODE_READ))
1376 nfsi->flags |= invalid; 1436 nfsi->cache_validity |= invalid;
1377 1437
1438 spin_unlock(&inode->i_lock);
1378 return 0; 1439 return 0;
1379 out_changed: 1440 out_changed:
1380 /* 1441 /*
@@ -1391,7 +1452,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1391 */ 1452 */
1392 nfs_invalidate_inode(inode); 1453 nfs_invalidate_inode(inode);
1393 out_err: 1454 out_err:
1394 NFS_FLAGS(inode) |= NFS_INO_STALE; 1455 set_bit(NFS_INO_STALE, &NFS_FLAGS(inode));
1395 return -ESTALE; 1456 return -ESTALE;
1396} 1457}
1397 1458
@@ -1950,7 +2011,8 @@ static struct inode *nfs_alloc_inode(struct super_block *sb)
1950 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); 2011 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL);
1951 if (!nfsi) 2012 if (!nfsi)
1952 return NULL; 2013 return NULL;
1953 nfsi->flags = 0; 2014 nfsi->flags = 0UL;
2015 nfsi->cache_validity = 0UL;
1954#ifdef CONFIG_NFS_V3_ACL 2016#ifdef CONFIG_NFS_V3_ACL
1955 nfsi->acl_access = ERR_PTR(-EAGAIN); 2017 nfsi->acl_access = ERR_PTR(-EAGAIN);
1956 nfsi->acl_default = ERR_PTR(-EAGAIN); 2018 nfsi->acl_default = ERR_PTR(-EAGAIN);
@@ -1982,7 +2044,6 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
1982 nfsi->ndirty = 0; 2044 nfsi->ndirty = 0;
1983 nfsi->ncommit = 0; 2045 nfsi->ncommit = 0;
1984 nfsi->npages = 0; 2046 nfsi->npages = 0;
1985 init_waitqueue_head(&nfsi->nfs_i_wait);
1986 nfs4_init_once(nfsi); 2047 nfs4_init_once(nfsi);
1987 } 2048 }
1988} 2049}
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 1b7a3ef2f813..6a5bbc0ae941 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -308,7 +308,9 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
308 nfs_begin_data_update(inode); 308 nfs_begin_data_update(inode);
309 status = rpc_call(server->client_acl, ACLPROC3_SETACL, 309 status = rpc_call(server->client_acl, ACLPROC3_SETACL,
310 &args, &fattr, 0); 310 &args, &fattr, 0);
311 NFS_FLAGS(inode) |= NFS_INO_INVALID_ACCESS; 311 spin_lock(&inode->i_lock);
312 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS;
313 spin_unlock(&inode->i_lock);
312 nfs_end_data_update(inode); 314 nfs_end_data_update(inode);
313 dprintk("NFS reply setacl: %d\n", status); 315 dprintk("NFS reply setacl: %d\n", status);
314 316
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 7851569b31c6..edc95514046d 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -34,8 +34,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
34 res = rpc_call_sync(clnt, msg, flags); 34 res = rpc_call_sync(clnt, msg, flags);
35 if (res != -EJUKEBOX) 35 if (res != -EJUKEBOX)
36 break; 36 break;
37 set_current_state(TASK_INTERRUPTIBLE); 37 schedule_timeout_interruptible(NFS_JUKEBOX_RETRY_TIME);
38 schedule_timeout(NFS_JUKEBOX_RETRY_TIME);
39 res = -ERESTARTSYS; 38 res = -ERESTARTSYS;
40 } while (!signalled()); 39 } while (!signalled());
41 rpc_clnt_sigunmask(clnt, &oldset); 40 rpc_clnt_sigunmask(clnt, &oldset);
@@ -120,6 +119,8 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
120 dprintk("NFS call setattr\n"); 119 dprintk("NFS call setattr\n");
121 fattr->valid = 0; 120 fattr->valid = 0;
122 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0); 121 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0);
122 if (status == 0)
123 nfs_setattr_update_inode(inode, sattr);
123 dprintk("NFS reply setattr: %d\n", status); 124 dprintk("NFS reply setattr: %d\n", status);
124 return status; 125 return status;
125} 126}
@@ -370,6 +371,8 @@ again:
370 * not sure this buys us anything (and I'd have 371 * not sure this buys us anything (and I'd have
371 * to revamp the NFSv3 XDR code) */ 372 * to revamp the NFSv3 XDR code) */
372 status = nfs3_proc_setattr(dentry, &fattr, sattr); 373 status = nfs3_proc_setattr(dentry, &fattr, sattr);
374 if (status == 0)
375 nfs_setattr_update_inode(dentry->d_inode, sattr);
373 nfs_refresh_inode(dentry->d_inode, &fattr); 376 nfs_refresh_inode(dentry->d_inode, &fattr);
374 dprintk("NFS reply setattr (post-create): %d\n", status); 377 dprintk("NFS reply setattr (post-create): %d\n", status);
375 } 378 }
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1b76f80aedb9..9701ca8c9428 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -753,6 +753,7 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
753 .rpc_argp = &arg, 753 .rpc_argp = &arg,
754 .rpc_resp = &res, 754 .rpc_resp = &res,
755 }; 755 };
756 int status;
756 757
757 fattr->valid = 0; 758 fattr->valid = 0;
758 759
@@ -762,7 +763,8 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
762 } else 763 } else
763 memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); 764 memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid));
764 765
765 return rpc_call_sync(server->client, &msg, 0); 766 status = rpc_call_sync(server->client, &msg, 0);
767 return status;
766} 768}
767 769
768static int nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr, 770static int nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
@@ -1145,6 +1147,8 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
1145 1147
1146 status = nfs4_do_setattr(NFS_SERVER(inode), fattr, 1148 status = nfs4_do_setattr(NFS_SERVER(inode), fattr,
1147 NFS_FH(inode), sattr, state); 1149 NFS_FH(inode), sattr, state);
1150 if (status == 0)
1151 nfs_setattr_update_inode(inode, sattr);
1148 if (state != NULL) 1152 if (state != NULL)
1149 nfs4_close_state(state, FMODE_WRITE); 1153 nfs4_close_state(state, FMODE_WRITE);
1150 put_rpccred(cred); 1154 put_rpccred(cred);
@@ -1449,8 +1453,10 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
1449 struct nfs_fattr fattr; 1453 struct nfs_fattr fattr;
1450 status = nfs4_do_setattr(NFS_SERVER(dir), &fattr, 1454 status = nfs4_do_setattr(NFS_SERVER(dir), &fattr,
1451 NFS_FH(state->inode), sattr, state); 1455 NFS_FH(state->inode), sattr, state);
1452 if (status == 0) 1456 if (status == 0) {
1457 nfs_setattr_update_inode(state->inode, sattr);
1453 goto out; 1458 goto out;
1459 }
1454 } else if (flags != 0) 1460 } else if (flags != 0)
1455 goto out; 1461 goto out;
1456 nfs4_close_state(state, flags); 1462 nfs4_close_state(state, flags);
@@ -2412,14 +2418,11 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
2412 *timeout = NFS4_POLL_RETRY_MAX; 2418 *timeout = NFS4_POLL_RETRY_MAX;
2413 rpc_clnt_sigmask(clnt, &oldset); 2419 rpc_clnt_sigmask(clnt, &oldset);
2414 if (clnt->cl_intr) { 2420 if (clnt->cl_intr) {
2415 set_current_state(TASK_INTERRUPTIBLE); 2421 schedule_timeout_interruptible(*timeout);
2416 schedule_timeout(*timeout);
2417 if (signalled()) 2422 if (signalled())
2418 res = -ERESTARTSYS; 2423 res = -ERESTARTSYS;
2419 } else { 2424 } else
2420 set_current_state(TASK_UNINTERRUPTIBLE); 2425 schedule_timeout_uninterruptible(*timeout);
2421 schedule_timeout(*timeout);
2422 }
2423 rpc_clnt_sigunmask(clnt, &oldset); 2426 rpc_clnt_sigunmask(clnt, &oldset);
2424 *timeout <<= 1; 2427 *timeout <<= 1;
2425 return res; 2428 return res;
@@ -2572,8 +2575,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
2572static unsigned long 2575static unsigned long
2573nfs4_set_lock_task_retry(unsigned long timeout) 2576nfs4_set_lock_task_retry(unsigned long timeout)
2574{ 2577{
2575 current->state = TASK_INTERRUPTIBLE; 2578 schedule_timeout_interruptible(timeout);
2576 schedule_timeout(timeout);
2577 timeout <<= 1; 2579 timeout <<= 1;
2578 if (timeout > NFS4_LOCK_MAXTIMEOUT) 2580 if (timeout > NFS4_LOCK_MAXTIMEOUT)
2579 return NFS4_LOCK_MAXTIMEOUT; 2581 return NFS4_LOCK_MAXTIMEOUT;
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index cedf636bcf3c..be23c3fb9260 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -114,6 +114,8 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
114 dprintk("NFS call setattr\n"); 114 dprintk("NFS call setattr\n");
115 fattr->valid = 0; 115 fattr->valid = 0;
116 status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0); 116 status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0);
117 if (status == 0)
118 nfs_setattr_update_inode(inode, sattr);
117 dprintk("NFS reply setattr: %d\n", status); 119 dprintk("NFS reply setattr: %d\n", status);
118 return status; 120 return status;
119} 121}
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6f866b8aa2d5..6ceb1d471f20 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -140,7 +140,9 @@ static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode,
140 if (rdata->res.eof != 0 || result == 0) 140 if (rdata->res.eof != 0 || result == 0)
141 break; 141 break;
142 } while (count); 142 } while (count);
143 NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME; 143 spin_lock(&inode->i_lock);
144 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
145 spin_unlock(&inode->i_lock);
144 146
145 if (count) 147 if (count)
146 memclear_highpage_flush(page, rdata->args.pgbase, count); 148 memclear_highpage_flush(page, rdata->args.pgbase, count);
@@ -473,7 +475,9 @@ void nfs_readpage_result(struct rpc_task *task)
473 } 475 }
474 task->tk_status = -EIO; 476 task->tk_status = -EIO;
475 } 477 }
476 NFS_FLAGS(data->inode) |= NFS_INO_INVALID_ATIME; 478 spin_lock(&data->inode->i_lock);
479 NFS_I(data->inode)->cache_validity |= NFS_INO_INVALID_ATIME;
480 spin_unlock(&data->inode->i_lock);
477 data->complete(data, status); 481 data->complete(data, status);
478} 482}
479 483
diff --git a/fs/nfs/symlink.c b/fs/nfs/symlink.c
index 35f106599144..18dc95b0b646 100644
--- a/fs/nfs/symlink.c
+++ b/fs/nfs/symlink.c
@@ -27,26 +27,14 @@
27 27
28/* Symlink caching in the page cache is even more simplistic 28/* Symlink caching in the page cache is even more simplistic
29 * and straight-forward than readdir caching. 29 * and straight-forward than readdir caching.
30 *
31 * At the beginning of the page we store pointer to struct page in question,
32 * simplifying nfs_put_link() (if inode got invalidated we can't find the page
33 * to be freed via pagecache lookup).
34 * The NUL-terminated string follows immediately thereafter.
35 */ 30 */
36 31
37struct nfs_symlink {
38 struct page *page;
39 char body[0];
40};
41
42static int nfs_symlink_filler(struct inode *inode, struct page *page) 32static int nfs_symlink_filler(struct inode *inode, struct page *page)
43{ 33{
44 const unsigned int pgbase = offsetof(struct nfs_symlink, body);
45 const unsigned int pglen = PAGE_SIZE - pgbase;
46 int error; 34 int error;
47 35
48 lock_kernel(); 36 lock_kernel();
49 error = NFS_PROTO(inode)->readlink(inode, page, pgbase, pglen); 37 error = NFS_PROTO(inode)->readlink(inode, page, 0, PAGE_SIZE);
50 unlock_kernel(); 38 unlock_kernel();
51 if (error < 0) 39 if (error < 0)
52 goto error; 40 goto error;
@@ -60,11 +48,10 @@ error:
60 return -EIO; 48 return -EIO;
61} 49}
62 50
63static int nfs_follow_link(struct dentry *dentry, struct nameidata *nd) 51static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
64{ 52{
65 struct inode *inode = dentry->d_inode; 53 struct inode *inode = dentry->d_inode;
66 struct page *page; 54 struct page *page;
67 struct nfs_symlink *p;
68 void *err = ERR_PTR(nfs_revalidate_inode(NFS_SERVER(inode), inode)); 55 void *err = ERR_PTR(nfs_revalidate_inode(NFS_SERVER(inode), inode));
69 if (err) 56 if (err)
70 goto read_failed; 57 goto read_failed;
@@ -78,28 +65,20 @@ static int nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
78 err = ERR_PTR(-EIO); 65 err = ERR_PTR(-EIO);
79 goto getlink_read_error; 66 goto getlink_read_error;
80 } 67 }
81 p = kmap(page); 68 nd_set_link(nd, kmap(page));
82 p->page = page; 69 return page;
83 nd_set_link(nd, p->body);
84 return 0;
85 70
86getlink_read_error: 71getlink_read_error:
87 page_cache_release(page); 72 page_cache_release(page);
88read_failed: 73read_failed:
89 nd_set_link(nd, err); 74 nd_set_link(nd, err);
90 return 0; 75 return NULL;
91} 76}
92 77
93static void nfs_put_link(struct dentry *dentry, struct nameidata *nd) 78static void nfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
94{ 79{
95 char *s = nd_get_link(nd); 80 if (cookie) {
96 if (!IS_ERR(s)) { 81 struct page *page = cookie;
97 struct nfs_symlink *p;
98 struct page *page;
99
100 p = container_of(s, struct nfs_symlink, body[0]);
101 page = p->page;
102
103 kunmap(page); 82 kunmap(page);
104 page_cache_release(page); 83 page_cache_release(page);
105 } 84 }