diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-06-22 13:16:30 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-06-22 16:07:37 -0400 |
commit | fe51beecc55d0b0dce289e4758e7c529a642f63e (patch) | |
tree | 9790d77fafbb52b9237ecd65c57002e87f914e12 /fs/nfs/inode.c | |
parent | 7d52e86274e09fce8ac8f963e3605a84d0a305a7 (diff) |
[PATCH] NFS: Ensure that fstat() always returns the correct mtime
Even if the file is open for writes.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index a3922f4cc0a8..4f545f382ba6 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -620,9 +620,9 @@ nfs_zap_caches(struct inode *inode) | |||
620 | 620 | ||
621 | memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); | 621 | memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); |
622 | if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) | 622 | 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; | 623 | nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; |
624 | else | 624 | else |
625 | nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | 625 | nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; |
626 | } | 626 | } |
627 | 627 | ||
628 | static void nfs_zap_acl_cache(struct inode *inode) | 628 | static void nfs_zap_acl_cache(struct inode *inode) |
@@ -1055,6 +1055,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1055 | goto out; | 1055 | goto out; |
1056 | } | 1056 | } |
1057 | flags = nfsi->flags; | 1057 | flags = nfsi->flags; |
1058 | nfsi->flags &= ~NFS_INO_REVAL_PAGECACHE; | ||
1058 | /* | 1059 | /* |
1059 | * We may need to keep the attributes marked as invalid if | 1060 | * We may need to keep the attributes marked as invalid if |
1060 | * we raced with nfs_end_attr_update(). | 1061 | * we raced with nfs_end_attr_update(). |
@@ -1187,8 +1188,11 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1187 | if ((fattr->valid & NFS_ATTR_PRE_CHANGE) != 0 | 1188 | if ((fattr->valid & NFS_ATTR_PRE_CHANGE) != 0 |
1188 | && nfsi->change_attr == fattr->pre_change_attr) | 1189 | && nfsi->change_attr == fattr->pre_change_attr) |
1189 | nfsi->change_attr = fattr->change_attr; | 1190 | nfsi->change_attr = fattr->change_attr; |
1190 | if (!data_unstable && nfsi->change_attr != fattr->change_attr) | 1191 | if (nfsi->change_attr != fattr->change_attr) { |
1191 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1192 | nfsi->flags |= NFS_INO_INVALID_ATTR; |
1193 | if (!data_unstable) | ||
1194 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | ||
1195 | } | ||
1192 | } | 1196 | } |
1193 | 1197 | ||
1194 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) | 1198 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) |
@@ -1211,12 +1215,16 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1211 | } | 1215 | } |
1212 | 1216 | ||
1213 | /* Verify a few of the more important attributes */ | 1217 | /* Verify a few of the more important attributes */ |
1214 | if (!data_unstable) { | 1218 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { |
1215 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime) | ||
1216 | || cur_size != new_isize) | ||
1217 | nfsi->flags |= NFS_INO_INVALID_ATTR; | ||
1218 | } else if (new_isize != cur_size && nfsi->npages == 0) | ||
1219 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1219 | nfsi->flags |= NFS_INO_INVALID_ATTR; |
1220 | if (!data_unstable) | ||
1221 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | ||
1222 | } | ||
1223 | if (cur_size != new_isize) { | ||
1224 | nfsi->flags |= NFS_INO_INVALID_ATTR; | ||
1225 | if (nfsi->npages == 0) | ||
1226 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | ||
1227 | } | ||
1220 | 1228 | ||
1221 | /* Have any file permissions changed? */ | 1229 | /* Have any file permissions changed? */ |
1222 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) | 1230 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) |