diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-10-17 19:08:46 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-10-18 12:14:34 -0400 |
commit | a9a4a87a5942e9271523197a90aaa82349c818fb (patch) | |
tree | 88001fc58944798ff41d36a08ccf2bdace2cda6e | |
parent | 919066d690541f4bd727b0e0fc2f7a20a7e3b3a7 (diff) |
NFS: Use the inode->i_version to cache NFSv4 change attribute information
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/delegation.c | 2 | ||||
-rw-r--r-- | fs/nfs/fscache-index.c | 4 | ||||
-rw-r--r-- | fs/nfs/inode.c | 16 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 4 | ||||
-rw-r--r-- | fs/nfs/write.c | 2 | ||||
-rw-r--r-- | include/linux/nfs_fs.h | 1 |
6 files changed, 14 insertions, 15 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 321a66bc3846..7f2654069806 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -240,7 +240,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
240 | sizeof(delegation->stateid.data)); | 240 | sizeof(delegation->stateid.data)); |
241 | delegation->type = res->delegation_type; | 241 | delegation->type = res->delegation_type; |
242 | delegation->maxsize = res->maxsize; | 242 | delegation->maxsize = res->maxsize; |
243 | delegation->change_attr = nfsi->change_attr; | 243 | delegation->change_attr = inode->i_version; |
244 | delegation->cred = get_rpccred(cred); | 244 | delegation->cred = get_rpccred(cred); |
245 | delegation->inode = inode; | 245 | delegation->inode = inode; |
246 | delegation->flags = 1<<NFS_DELEGATION_REFERENCED; | 246 | delegation->flags = 1<<NFS_DELEGATION_REFERENCED; |
diff --git a/fs/nfs/fscache-index.c b/fs/nfs/fscache-index.c index 5b1006480bc2..7cf2c4699b08 100644 --- a/fs/nfs/fscache-index.c +++ b/fs/nfs/fscache-index.c | |||
@@ -212,7 +212,7 @@ static uint16_t nfs_fscache_inode_get_aux(const void *cookie_netfs_data, | |||
212 | auxdata.ctime = nfsi->vfs_inode.i_ctime; | 212 | auxdata.ctime = nfsi->vfs_inode.i_ctime; |
213 | 213 | ||
214 | if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) | 214 | if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) |
215 | auxdata.change_attr = nfsi->change_attr; | 215 | auxdata.change_attr = nfsi->vfs_inode.i_version; |
216 | 216 | ||
217 | if (bufmax > sizeof(auxdata)) | 217 | if (bufmax > sizeof(auxdata)) |
218 | bufmax = sizeof(auxdata); | 218 | bufmax = sizeof(auxdata); |
@@ -244,7 +244,7 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data, | |||
244 | auxdata.ctime = nfsi->vfs_inode.i_ctime; | 244 | auxdata.ctime = nfsi->vfs_inode.i_ctime; |
245 | 245 | ||
246 | if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) | 246 | if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) |
247 | auxdata.change_attr = nfsi->change_attr; | 247 | auxdata.change_attr = nfsi->vfs_inode.i_version; |
248 | 248 | ||
249 | if (memcmp(data, &auxdata, datalen) != 0) | 249 | if (memcmp(data, &auxdata, datalen) != 0) |
250 | return FSCACHE_CHECKAUX_OBSOLETE; | 250 | return FSCACHE_CHECKAUX_OBSOLETE; |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index fe1203797b2b..4dc6d078f108 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -318,7 +318,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
318 | memset(&inode->i_atime, 0, sizeof(inode->i_atime)); | 318 | memset(&inode->i_atime, 0, sizeof(inode->i_atime)); |
319 | memset(&inode->i_mtime, 0, sizeof(inode->i_mtime)); | 319 | memset(&inode->i_mtime, 0, sizeof(inode->i_mtime)); |
320 | memset(&inode->i_ctime, 0, sizeof(inode->i_ctime)); | 320 | memset(&inode->i_ctime, 0, sizeof(inode->i_ctime)); |
321 | nfsi->change_attr = 0; | 321 | inode->i_version = 0; |
322 | inode->i_size = 0; | 322 | inode->i_size = 0; |
323 | inode->i_nlink = 0; | 323 | inode->i_nlink = 0; |
324 | inode->i_uid = -2; | 324 | inode->i_uid = -2; |
@@ -344,7 +344,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
344 | | NFS_INO_INVALID_ACCESS | 344 | | NFS_INO_INVALID_ACCESS |
345 | | NFS_INO_INVALID_ACL; | 345 | | NFS_INO_INVALID_ACL; |
346 | if (fattr->valid & NFS_ATTR_FATTR_CHANGE) | 346 | if (fattr->valid & NFS_ATTR_FATTR_CHANGE) |
347 | nfsi->change_attr = fattr->change_attr; | 347 | inode->i_version = fattr->change_attr; |
348 | else if (nfs_server_capable(inode, NFS_CAP_CHANGE_ATTR)) | 348 | else if (nfs_server_capable(inode, NFS_CAP_CHANGE_ATTR)) |
349 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR | 349 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR |
350 | | NFS_INO_INVALID_DATA; | 350 | | NFS_INO_INVALID_DATA; |
@@ -897,8 +897,8 @@ static unsigned long nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr | |||
897 | 897 | ||
898 | if ((fattr->valid & NFS_ATTR_FATTR_PRECHANGE) | 898 | if ((fattr->valid & NFS_ATTR_FATTR_PRECHANGE) |
899 | && (fattr->valid & NFS_ATTR_FATTR_CHANGE) | 899 | && (fattr->valid & NFS_ATTR_FATTR_CHANGE) |
900 | && nfsi->change_attr == fattr->pre_change_attr) { | 900 | && inode->i_version == fattr->pre_change_attr) { |
901 | nfsi->change_attr = fattr->change_attr; | 901 | inode->i_version = fattr->change_attr; |
902 | if (S_ISDIR(inode->i_mode)) | 902 | if (S_ISDIR(inode->i_mode)) |
903 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | 903 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
904 | ret |= NFS_INO_INVALID_ATTR; | 904 | ret |= NFS_INO_INVALID_ATTR; |
@@ -952,7 +952,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
952 | return -EIO; | 952 | return -EIO; |
953 | 953 | ||
954 | if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && | 954 | if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && |
955 | nfsi->change_attr != fattr->change_attr) | 955 | inode->i_version != fattr->change_attr) |
956 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 956 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
957 | 957 | ||
958 | /* Verify a few of the more important attributes */ | 958 | /* Verify a few of the more important attributes */ |
@@ -1163,7 +1163,7 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa | |||
1163 | } | 1163 | } |
1164 | if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && | 1164 | if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && |
1165 | (fattr->valid & NFS_ATTR_FATTR_PRECHANGE) == 0) { | 1165 | (fattr->valid & NFS_ATTR_FATTR_PRECHANGE) == 0) { |
1166 | fattr->pre_change_attr = NFS_I(inode)->change_attr; | 1166 | fattr->pre_change_attr = inode->i_version; |
1167 | fattr->valid |= NFS_ATTR_FATTR_PRECHANGE; | 1167 | fattr->valid |= NFS_ATTR_FATTR_PRECHANGE; |
1168 | } | 1168 | } |
1169 | if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 && | 1169 | if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 && |
@@ -1244,13 +1244,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1244 | 1244 | ||
1245 | /* More cache consistency checks */ | 1245 | /* More cache consistency checks */ |
1246 | if (fattr->valid & NFS_ATTR_FATTR_CHANGE) { | 1246 | if (fattr->valid & NFS_ATTR_FATTR_CHANGE) { |
1247 | if (nfsi->change_attr != fattr->change_attr) { | 1247 | if (inode->i_version != fattr->change_attr) { |
1248 | dprintk("NFS: change_attr change on server for file %s/%ld\n", | 1248 | dprintk("NFS: change_attr change on server for file %s/%ld\n", |
1249 | inode->i_sb->s_id, inode->i_ino); | 1249 | inode->i_sb->s_id, inode->i_ino); |
1250 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | 1250 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; |
1251 | if (S_ISDIR(inode->i_mode)) | 1251 | if (S_ISDIR(inode->i_mode)) |
1252 | nfs_force_lookup_revalidate(inode); | 1252 | nfs_force_lookup_revalidate(inode); |
1253 | nfsi->change_attr = fattr->change_attr; | 1253 | inode->i_version = fattr->change_attr; |
1254 | } | 1254 | } |
1255 | } else if (server->caps & NFS_CAP_CHANGE_ATTR) | 1255 | } else if (server->caps & NFS_CAP_CHANGE_ATTR) |
1256 | invalid |= save_cache_validity; | 1256 | invalid |= save_cache_validity; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4700fae1ada0..0f0b6076de62 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -753,9 +753,9 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) | |||
753 | 753 | ||
754 | spin_lock(&dir->i_lock); | 754 | spin_lock(&dir->i_lock); |
755 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; | 755 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; |
756 | if (!cinfo->atomic || cinfo->before != nfsi->change_attr) | 756 | if (!cinfo->atomic || cinfo->before != dir->i_version) |
757 | nfs_force_lookup_revalidate(dir); | 757 | nfs_force_lookup_revalidate(dir); |
758 | nfsi->change_attr = cinfo->after; | 758 | dir->i_version = cinfo->after; |
759 | spin_unlock(&dir->i_lock); | 759 | spin_unlock(&dir->i_lock); |
760 | } | 760 | } |
761 | 761 | ||
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 106fd0634ab3..2084a6494218 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -390,7 +390,7 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
390 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); | 390 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); |
391 | BUG_ON(error); | 391 | BUG_ON(error); |
392 | if (!nfsi->npages && nfs_have_delegation(inode, FMODE_WRITE)) | 392 | if (!nfsi->npages && nfs_have_delegation(inode, FMODE_WRITE)) |
393 | nfsi->change_attr++; | 393 | inode->i_version++; |
394 | set_bit(PG_MAPPED, &req->wb_flags); | 394 | set_bit(PG_MAPPED, &req->wb_flags); |
395 | SetPagePrivate(req->wb_page); | 395 | SetPagePrivate(req->wb_page); |
396 | set_page_private(req->wb_page, (unsigned long)req); | 396 | set_page_private(req->wb_page, (unsigned long)req); |
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index eaac770f886e..60a137b7f171 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h | |||
@@ -149,7 +149,6 @@ struct nfs_inode { | |||
149 | unsigned long read_cache_jiffies; | 149 | unsigned long read_cache_jiffies; |
150 | unsigned long attrtimeo; | 150 | unsigned long attrtimeo; |
151 | unsigned long attrtimeo_timestamp; | 151 | unsigned long attrtimeo_timestamp; |
152 | __u64 change_attr; /* v4 only */ | ||
153 | 152 | ||
154 | unsigned long attr_gencount; | 153 | unsigned long attr_gencount; |
155 | /* "Generation counter" for the attribute cache. This is | 154 | /* "Generation counter" for the attribute cache. This is |