diff options
author | Chuck Lever <cel@citi.umich.edu> | 2005-08-18 14:24:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-08-18 15:53:56 -0400 |
commit | 5529680981807b44abf3be30fb6d612ff04f68ff (patch) | |
tree | 57da4e9135c0a85c1f8c6bc797250c0209420b51 /fs/nfs/inode.c | |
parent | 3c7bf1eaee1255315fc7c2c4c300295e556ef768 (diff) |
[PATCH] NFS: split nfsi->flags into two fields
Certain bits in nfsi->flags can be manipulated with atomic bitops, and some
are better manipulated via logical bitmask operations.
This patch splits the flags field into two. The next patch introduces atomic
bitops for one of the fields.
Test plan:
Millions of fsx ops on SMP clients.
Signed-off-by: Chuck Lever <cel@netapp.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index bb7ca022bcb2..622184553516 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|NFS_INO_REVAL_PAGECACHE; | 623 | 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 | 624 | else |
625 | nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; | 625 | nfsi->cache_validity |= 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) |
@@ -632,7 +632,7 @@ static void nfs_zap_acl_cache(struct inode *inode) | |||
632 | clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; | 632 | clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; |
633 | if (clear_acl_cache != NULL) | 633 | if (clear_acl_cache != NULL) |
634 | clear_acl_cache(inode); | 634 | clear_acl_cache(inode); |
635 | NFS_I(inode)->flags &= ~NFS_INO_INVALID_ACL; | 635 | NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL; |
636 | } | 636 | } |
637 | 637 | ||
638 | /* | 638 | /* |
@@ -841,7 +841,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) | |||
841 | inode->i_uid = attr->ia_uid; | 841 | inode->i_uid = attr->ia_uid; |
842 | if ((attr->ia_valid & ATTR_GID) != 0) | 842 | if ((attr->ia_valid & ATTR_GID) != 0) |
843 | inode->i_gid = attr->ia_gid; | 843 | inode->i_gid = attr->ia_gid; |
844 | NFS_FLAGS(inode) |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | 844 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; |
845 | } | 845 | } |
846 | if ((attr->ia_valid & ATTR_SIZE) != 0) { | 846 | if ((attr->ia_valid & ATTR_SIZE) != 0) { |
847 | inode->i_size = attr->ia_size; | 847 | inode->i_size = attr->ia_size; |
@@ -872,8 +872,7 @@ nfs_wait_on_inode(struct inode *inode, int flag) | |||
872 | int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | 872 | int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) |
873 | { | 873 | { |
874 | struct inode *inode = dentry->d_inode; | 874 | struct inode *inode = dentry->d_inode; |
875 | struct nfs_inode *nfsi = NFS_I(inode); | 875 | int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; |
876 | int need_atime = nfsi->flags & NFS_INO_INVALID_ATIME; | ||
877 | int err; | 876 | int err; |
878 | 877 | ||
879 | if (__IS_FLG(inode, MS_NOATIME)) | 878 | if (__IS_FLG(inode, MS_NOATIME)) |
@@ -1019,7 +1018,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1019 | struct nfs_fattr fattr; | 1018 | struct nfs_fattr fattr; |
1020 | struct nfs_inode *nfsi = NFS_I(inode); | 1019 | struct nfs_inode *nfsi = NFS_I(inode); |
1021 | unsigned long verifier; | 1020 | unsigned long verifier; |
1022 | unsigned int flags; | 1021 | unsigned long cache_validity; |
1023 | 1022 | ||
1024 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", | 1023 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", |
1025 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); | 1024 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); |
@@ -1036,7 +1035,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1036 | goto out_nowait; | 1035 | goto out_nowait; |
1037 | if (NFS_ATTRTIMEO(inode) == 0) | 1036 | if (NFS_ATTRTIMEO(inode) == 0) |
1038 | continue; | 1037 | continue; |
1039 | if (NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) | 1038 | if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ATIME)) |
1040 | continue; | 1039 | continue; |
1041 | status = NFS_STALE(inode) ? -ESTALE : 0; | 1040 | status = NFS_STALE(inode) ? -ESTALE : 0; |
1042 | goto out_nowait; | 1041 | goto out_nowait; |
@@ -1065,18 +1064,21 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
1065 | (long long)NFS_FILEID(inode), status); | 1064 | (long long)NFS_FILEID(inode), status); |
1066 | goto out; | 1065 | goto out; |
1067 | } | 1066 | } |
1068 | flags = nfsi->flags; | 1067 | cache_validity = nfsi->cache_validity; |
1069 | nfsi->flags &= ~NFS_INO_REVAL_PAGECACHE; | 1068 | nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; |
1069 | |||
1070 | /* | 1070 | /* |
1071 | * We may need to keep the attributes marked as invalid if | 1071 | * We may need to keep the attributes marked as invalid if |
1072 | * we raced with nfs_end_attr_update(). | 1072 | * we raced with nfs_end_attr_update(). |
1073 | */ | 1073 | */ |
1074 | if (verifier == nfsi->cache_change_attribute) | 1074 | if (verifier == nfsi->cache_change_attribute) |
1075 | nfsi->flags &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); | 1075 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); |
1076 | /* Do the page cache invalidation */ | 1076 | |
1077 | nfs_revalidate_mapping(inode, inode->i_mapping); | 1077 | nfs_revalidate_mapping(inode, inode->i_mapping); |
1078 | if (flags & NFS_INO_INVALID_ACL) | 1078 | |
1079 | if (cache_validity & NFS_INO_INVALID_ACL) | ||
1079 | nfs_zap_acl_cache(inode); | 1080 | nfs_zap_acl_cache(inode); |
1081 | |||
1080 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n", | 1082 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) revalidation complete\n", |
1081 | inode->i_sb->s_id, | 1083 | inode->i_sb->s_id, |
1082 | (long long)NFS_FILEID(inode)); | 1084 | (long long)NFS_FILEID(inode)); |
@@ -1107,7 +1109,7 @@ int nfs_attribute_timeout(struct inode *inode) | |||
1107 | */ | 1109 | */ |
1108 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 1110 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
1109 | { | 1111 | { |
1110 | if (!(NFS_FLAGS(inode) & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) | 1112 | if (!(NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA)) |
1111 | && !nfs_attribute_timeout(inode)) | 1113 | && !nfs_attribute_timeout(inode)) |
1112 | return NFS_STALE(inode) ? -ESTALE : 0; | 1114 | return NFS_STALE(inode) ? -ESTALE : 0; |
1113 | return __nfs_revalidate_inode(server, inode); | 1115 | return __nfs_revalidate_inode(server, inode); |
@@ -1122,14 +1124,14 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) | |||
1122 | { | 1124 | { |
1123 | struct nfs_inode *nfsi = NFS_I(inode); | 1125 | struct nfs_inode *nfsi = NFS_I(inode); |
1124 | 1126 | ||
1125 | if (nfsi->flags & NFS_INO_INVALID_DATA) { | 1127 | if (nfsi->cache_validity & NFS_INO_INVALID_DATA) { |
1126 | if (S_ISREG(inode->i_mode)) { | 1128 | if (S_ISREG(inode->i_mode)) { |
1127 | if (filemap_fdatawrite(mapping) == 0) | 1129 | if (filemap_fdatawrite(mapping) == 0) |
1128 | filemap_fdatawait(mapping); | 1130 | filemap_fdatawait(mapping); |
1129 | nfs_wb_all(inode); | 1131 | nfs_wb_all(inode); |
1130 | } | 1132 | } |
1131 | invalidate_inode_pages2(mapping); | 1133 | invalidate_inode_pages2(mapping); |
1132 | nfsi->flags &= ~NFS_INO_INVALID_DATA; | 1134 | nfsi->cache_validity &= ~NFS_INO_INVALID_DATA; |
1133 | if (S_ISDIR(inode->i_mode)) { | 1135 | if (S_ISDIR(inode->i_mode)) { |
1134 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); | 1136 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); |
1135 | /* This ensures we revalidate child dentries */ | 1137 | /* This ensures we revalidate child dentries */ |
@@ -1164,10 +1166,10 @@ void nfs_end_data_update(struct inode *inode) | |||
1164 | 1166 | ||
1165 | if (!nfs_have_delegation(inode, FMODE_READ)) { | 1167 | if (!nfs_have_delegation(inode, FMODE_READ)) { |
1166 | /* Mark the attribute cache for revalidation */ | 1168 | /* Mark the attribute cache for revalidation */ |
1167 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1169 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1168 | /* Directories and symlinks: invalidate page cache too */ | 1170 | /* Directories and symlinks: invalidate page cache too */ |
1169 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) | 1171 | if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) |
1170 | nfsi->flags |= NFS_INO_INVALID_DATA; | 1172 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
1171 | } | 1173 | } |
1172 | nfsi->cache_change_attribute ++; | 1174 | nfsi->cache_change_attribute ++; |
1173 | atomic_dec(&nfsi->data_updates); | 1175 | atomic_dec(&nfsi->data_updates); |
@@ -1200,9 +1202,9 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1200 | && nfsi->change_attr == fattr->pre_change_attr) | 1202 | && nfsi->change_attr == fattr->pre_change_attr) |
1201 | nfsi->change_attr = fattr->change_attr; | 1203 | nfsi->change_attr = fattr->change_attr; |
1202 | if (nfsi->change_attr != fattr->change_attr) { | 1204 | if (nfsi->change_attr != fattr->change_attr) { |
1203 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1205 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1204 | if (!data_unstable) | 1206 | if (!data_unstable) |
1205 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | 1207 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
1206 | } | 1208 | } |
1207 | } | 1209 | } |
1208 | 1210 | ||
@@ -1227,28 +1229,28 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1227 | 1229 | ||
1228 | /* Verify a few of the more important attributes */ | 1230 | /* Verify a few of the more important attributes */ |
1229 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { | 1231 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { |
1230 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1232 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1231 | if (!data_unstable) | 1233 | if (!data_unstable) |
1232 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | 1234 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
1233 | } | 1235 | } |
1234 | if (cur_size != new_isize) { | 1236 | if (cur_size != new_isize) { |
1235 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1237 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1236 | if (nfsi->npages == 0) | 1238 | if (nfsi->npages == 0) |
1237 | nfsi->flags |= NFS_INO_REVAL_PAGECACHE; | 1239 | nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; |
1238 | } | 1240 | } |
1239 | 1241 | ||
1240 | /* Have any file permissions changed? */ | 1242 | /* Have any file permissions changed? */ |
1241 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) | 1243 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) |
1242 | || inode->i_uid != fattr->uid | 1244 | || inode->i_uid != fattr->uid |
1243 | || inode->i_gid != fattr->gid) | 1245 | || inode->i_gid != fattr->gid) |
1244 | nfsi->flags |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; | 1246 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; |
1245 | 1247 | ||
1246 | /* Has the link count changed? */ | 1248 | /* Has the link count changed? */ |
1247 | if (inode->i_nlink != fattr->nlink) | 1249 | if (inode->i_nlink != fattr->nlink) |
1248 | nfsi->flags |= NFS_INO_INVALID_ATTR; | 1250 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; |
1249 | 1251 | ||
1250 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) | 1252 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) |
1251 | nfsi->flags |= NFS_INO_INVALID_ATIME; | 1253 | nfsi->cache_validity |= NFS_INO_INVALID_ATIME; |
1252 | 1254 | ||
1253 | nfsi->read_cache_jiffies = fattr->timestamp; | 1255 | nfsi->read_cache_jiffies = fattr->timestamp; |
1254 | return 0; | 1256 | return 0; |
@@ -1384,7 +1386,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign | |||
1384 | || S_ISLNK(inode->i_mode))) | 1386 | || S_ISLNK(inode->i_mode))) |
1385 | invalid &= ~NFS_INO_INVALID_DATA; | 1387 | invalid &= ~NFS_INO_INVALID_DATA; |
1386 | if (!nfs_have_delegation(inode, FMODE_READ)) | 1388 | if (!nfs_have_delegation(inode, FMODE_READ)) |
1387 | nfsi->flags |= invalid; | 1389 | nfsi->cache_validity |= invalid; |
1388 | 1390 | ||
1389 | return 0; | 1391 | return 0; |
1390 | out_changed: | 1392 | out_changed: |
@@ -1961,7 +1963,8 @@ static struct inode *nfs_alloc_inode(struct super_block *sb) | |||
1961 | nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); | 1963 | nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); |
1962 | if (!nfsi) | 1964 | if (!nfsi) |
1963 | return NULL; | 1965 | return NULL; |
1964 | nfsi->flags = 0; | 1966 | nfsi->flags = 0UL; |
1967 | nfsi->cache_validity = 0UL; | ||
1965 | #ifdef CONFIG_NFS_V3_ACL | 1968 | #ifdef CONFIG_NFS_V3_ACL |
1966 | nfsi->acl_access = ERR_PTR(-EAGAIN); | 1969 | nfsi->acl_access = ERR_PTR(-EAGAIN); |
1967 | nfsi->acl_default = ERR_PTR(-EAGAIN); | 1970 | nfsi->acl_default = ERR_PTR(-EAGAIN); |