diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-02-05 17:44:22 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-02-13 01:40:30 -0500 |
commit | b0c4fddca2bc3967381b728732a8850de35e1b20 (patch) | |
tree | 20c84b8927e448ab57f5536a4369e6f787ba316e | |
parent | 3e7d950a528454ad749a264feef3c8bad3faa108 (diff) |
NFS: Cleanup - avoid rereading 'jiffies' more than once in the same routine
Micro-optimisations for nfs_fhget() and nfs_wcc_update_inode().
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/inode.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 93269c3dd0f3..af53c02f473b 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -240,6 +240,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
240 | 240 | ||
241 | if (inode->i_state & I_NEW) { | 241 | if (inode->i_state & I_NEW) { |
242 | struct nfs_inode *nfsi = NFS_I(inode); | 242 | struct nfs_inode *nfsi = NFS_I(inode); |
243 | unsigned long now = jiffies; | ||
243 | 244 | ||
244 | /* We set i_ino for the few things that still rely on it, | 245 | /* We set i_ino for the few things that still rely on it, |
245 | * such as stat(2) */ | 246 | * such as stat(2) */ |
@@ -276,7 +277,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
276 | init_special_inode(inode, inode->i_mode, fattr->rdev); | 277 | init_special_inode(inode, inode->i_mode, fattr->rdev); |
277 | 278 | ||
278 | nfsi->read_cache_jiffies = fattr->time_start; | 279 | nfsi->read_cache_jiffies = fattr->time_start; |
279 | nfsi->last_updated = jiffies; | 280 | nfsi->last_updated = now; |
281 | nfsi->cache_change_attribute = now; | ||
280 | inode->i_atime = fattr->atime; | 282 | inode->i_atime = fattr->atime; |
281 | inode->i_mtime = fattr->mtime; | 283 | inode->i_mtime = fattr->mtime; |
282 | inode->i_ctime = fattr->ctime; | 284 | inode->i_ctime = fattr->ctime; |
@@ -295,7 +297,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) | |||
295 | inode->i_blocks = fattr->du.nfs2.blocks; | 297 | inode->i_blocks = fattr->du.nfs2.blocks; |
296 | } | 298 | } |
297 | nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); | 299 | nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); |
298 | nfsi->attrtimeo_timestamp = jiffies; | 300 | nfsi->attrtimeo_timestamp = now; |
299 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); | 301 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); |
300 | nfsi->access_cache = RB_ROOT; | 302 | nfsi->access_cache = RB_ROOT; |
301 | 303 | ||
@@ -788,20 +790,21 @@ void nfs_end_data_update(struct inode *inode) | |||
788 | static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | 790 | static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) |
789 | { | 791 | { |
790 | struct nfs_inode *nfsi = NFS_I(inode); | 792 | struct nfs_inode *nfsi = NFS_I(inode); |
793 | unsigned long now = jiffies; | ||
791 | 794 | ||
792 | /* If we have atomic WCC data, we may update some attributes */ | 795 | /* If we have atomic WCC data, we may update some attributes */ |
793 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { | 796 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { |
794 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) { | 797 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) { |
795 | memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); | 798 | memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); |
796 | nfsi->cache_change_attribute = jiffies; | 799 | nfsi->cache_change_attribute = now; |
797 | } | 800 | } |
798 | if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) { | 801 | if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) { |
799 | memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); | 802 | memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); |
800 | nfsi->cache_change_attribute = jiffies; | 803 | nfsi->cache_change_attribute = now; |
801 | } | 804 | } |
802 | if (inode->i_size == fattr->pre_size && nfsi->npages == 0) { | 805 | if (inode->i_size == fattr->pre_size && nfsi->npages == 0) { |
803 | inode->i_size = fattr->size; | 806 | inode->i_size = fattr->size; |
804 | nfsi->cache_change_attribute = jiffies; | 807 | nfsi->cache_change_attribute = now; |
805 | } | 808 | } |
806 | } | 809 | } |
807 | } | 810 | } |
@@ -1132,7 +1135,6 @@ struct inode *nfs_alloc_inode(struct super_block *sb) | |||
1132 | return NULL; | 1135 | return NULL; |
1133 | nfsi->flags = 0UL; | 1136 | nfsi->flags = 0UL; |
1134 | nfsi->cache_validity = 0UL; | 1137 | nfsi->cache_validity = 0UL; |
1135 | nfsi->cache_change_attribute = jiffies; | ||
1136 | #ifdef CONFIG_NFS_V3_ACL | 1138 | #ifdef CONFIG_NFS_V3_ACL |
1137 | nfsi->acl_access = ERR_PTR(-EAGAIN); | 1139 | nfsi->acl_access = ERR_PTR(-EAGAIN); |
1138 | nfsi->acl_default = ERR_PTR(-EAGAIN); | 1140 | nfsi->acl_default = ERR_PTR(-EAGAIN); |