diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-09-30 15:21:24 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-10-09 17:19:15 -0400 |
commit | 70ca88521fc7bee8ef0fc22033a439d4b9a2c70d (patch) | |
tree | 8e3943bfac55b59dc127393f8da0ecfc4aba424b /fs/nfs/inode.c | |
parent | b64e8a5ef758888cb42b7c105dcfaaf51aab1baf (diff) |
NFS: Fake up 'wcc' attributes to prevent cache invalidation after write
NFSv2 and v4 don't offer weak cache consistency attributes on WRITE calls.
In NFSv3, returning wcc data is optional. In all cases, we want to prevent
the client from invalidating our cached data whenever ->write_done()
attempts to update the inode attributes.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 23feb9e3d8b0..c5f4e0567533 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -793,6 +793,12 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
793 | { | 793 | { |
794 | struct nfs_inode *nfsi = NFS_I(inode); | 794 | struct nfs_inode *nfsi = NFS_I(inode); |
795 | 795 | ||
796 | if ((fattr->valid & NFS_ATTR_WCC_V4) != 0 && | ||
797 | nfsi->change_attr == fattr->pre_change_attr) { | ||
798 | nfsi->change_attr = fattr->change_attr; | ||
799 | if (S_ISDIR(inode->i_mode)) | ||
800 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | ||
801 | } | ||
796 | /* If we have atomic WCC data, we may update some attributes */ | 802 | /* If we have atomic WCC data, we may update some attributes */ |
797 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { | 803 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { |
798 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) | 804 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) |
@@ -923,6 +929,34 @@ out: | |||
923 | return status; | 929 | return status; |
924 | } | 930 | } |
925 | 931 | ||
932 | /** | ||
933 | * nfs_post_op_update_inode_force_wcc - try to update the inode attribute cache | ||
934 | * @inode - pointer to inode | ||
935 | * @fattr - updated attributes | ||
936 | * | ||
937 | * After an operation that has changed the inode metadata, mark the | ||
938 | * attribute cache as being invalid, then try to update it. Fake up | ||
939 | * weak cache consistency data, if none exist. | ||
940 | * | ||
941 | * This function is mainly designed to be used by the ->write_done() functions. | ||
942 | */ | ||
943 | int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr) | ||
944 | { | ||
945 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && | ||
946 | (fattr->valid & NFS_ATTR_WCC_V4) == 0) { | ||
947 | fattr->pre_change_attr = NFS_I(inode)->change_attr; | ||
948 | fattr->valid |= NFS_ATTR_WCC_V4; | ||
949 | } | ||
950 | if ((fattr->valid & NFS_ATTR_FATTR) != 0 && | ||
951 | (fattr->valid & NFS_ATTR_WCC) == 0) { | ||
952 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); | ||
953 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); | ||
954 | fattr->pre_size = inode->i_size; | ||
955 | fattr->valid |= NFS_ATTR_WCC; | ||
956 | } | ||
957 | return nfs_post_op_update_inode(inode, fattr); | ||
958 | } | ||
959 | |||
926 | /* | 960 | /* |
927 | * Many nfs protocol calls return the new file attributes after | 961 | * Many nfs protocol calls return the new file attributes after |
928 | * an operation. Here we update the inode to reflect the state | 962 | * an operation. Here we update the inode to reflect the state |