diff options
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r-- | fs/gfs2/inode.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index a31a4b80ba3c..3ef0f051d076 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -178,11 +178,11 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) | |||
178 | di->di_blocks = be64_to_cpu(str->di_blocks); | 178 | di->di_blocks = be64_to_cpu(str->di_blocks); |
179 | gfs2_set_inode_blocks(&ip->i_inode); | 179 | gfs2_set_inode_blocks(&ip->i_inode); |
180 | ip->i_inode.i_atime.tv_sec = be64_to_cpu(str->di_atime); | 180 | ip->i_inode.i_atime.tv_sec = be64_to_cpu(str->di_atime); |
181 | ip->i_inode.i_atime.tv_nsec = 0; | 181 | ip->i_inode.i_atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); |
182 | ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); | 182 | ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); |
183 | ip->i_inode.i_mtime.tv_nsec = 0; | 183 | ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec); |
184 | ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime); | 184 | ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime); |
185 | ip->i_inode.i_ctime.tv_nsec = 0; | 185 | ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); |
186 | 186 | ||
187 | di->di_goal_meta = be64_to_cpu(str->di_goal_meta); | 187 | di->di_goal_meta = be64_to_cpu(str->di_goal_meta); |
188 | di->di_goal_data = be64_to_cpu(str->di_goal_data); | 188 | di->di_goal_data = be64_to_cpu(str->di_goal_data); |
@@ -317,7 +317,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) | |||
317 | else | 317 | else |
318 | drop_nlink(&ip->i_inode); | 318 | drop_nlink(&ip->i_inode); |
319 | 319 | ||
320 | ip->i_inode.i_ctime = CURRENT_TIME_SEC; | 320 | ip->i_inode.i_ctime = CURRENT_TIME; |
321 | 321 | ||
322 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 322 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
323 | gfs2_dinode_out(ip, dibh->b_data); | 323 | gfs2_dinode_out(ip, dibh->b_data); |
@@ -648,6 +648,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
648 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); | 648 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
649 | struct gfs2_dinode *di; | 649 | struct gfs2_dinode *di; |
650 | struct buffer_head *dibh; | 650 | struct buffer_head *dibh; |
651 | struct timespec tv = CURRENT_TIME; | ||
651 | 652 | ||
652 | dibh = gfs2_meta_new(gl, inum->no_addr); | 653 | dibh = gfs2_meta_new(gl, inum->no_addr); |
653 | gfs2_trans_add_bh(gl, dibh, 1); | 654 | gfs2_trans_add_bh(gl, dibh, 1); |
@@ -663,7 +664,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
663 | di->di_nlink = 0; | 664 | di->di_nlink = 0; |
664 | di->di_size = 0; | 665 | di->di_size = 0; |
665 | di->di_blocks = cpu_to_be64(1); | 666 | di->di_blocks = cpu_to_be64(1); |
666 | di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds()); | 667 | di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(tv.tv_sec); |
667 | di->di_major = cpu_to_be32(MAJOR(dev)); | 668 | di->di_major = cpu_to_be32(MAJOR(dev)); |
668 | di->di_minor = cpu_to_be32(MINOR(dev)); | 669 | di->di_minor = cpu_to_be32(MINOR(dev)); |
669 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr); | 670 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr); |
@@ -693,6 +694,9 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
693 | di->di_entries = 0; | 694 | di->di_entries = 0; |
694 | memset(&di->__pad4, 0, sizeof(di->__pad4)); | 695 | memset(&di->__pad4, 0, sizeof(di->__pad4)); |
695 | di->di_eattr = 0; | 696 | di->di_eattr = 0; |
697 | di->di_atime_nsec = cpu_to_be32(tv.tv_nsec); | ||
698 | di->di_mtime_nsec = cpu_to_be32(tv.tv_nsec); | ||
699 | di->di_ctime_nsec = cpu_to_be32(tv.tv_nsec); | ||
696 | memset(&di->di_reserved, 0, sizeof(di->di_reserved)); | 700 | memset(&di->di_reserved, 0, sizeof(di->di_reserved)); |
697 | 701 | ||
698 | brelse(dibh); | 702 | brelse(dibh); |
@@ -1135,10 +1139,11 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) | |||
1135 | struct gfs2_glock *gl = gh->gh_gl; | 1139 | struct gfs2_glock *gl = gh->gh_gl; |
1136 | struct gfs2_sbd *sdp = gl->gl_sbd; | 1140 | struct gfs2_sbd *sdp = gl->gl_sbd; |
1137 | struct gfs2_inode *ip = gl->gl_object; | 1141 | struct gfs2_inode *ip = gl->gl_object; |
1138 | s64 curtime, quantum = gfs2_tune_get(sdp, gt_atime_quantum); | 1142 | s64 quantum = gfs2_tune_get(sdp, gt_atime_quantum); |
1139 | unsigned int state; | 1143 | unsigned int state; |
1140 | int flags; | 1144 | int flags; |
1141 | int error; | 1145 | int error; |
1146 | struct timespec tv = CURRENT_TIME; | ||
1142 | 1147 | ||
1143 | if (gfs2_assert_warn(sdp, gh->gh_flags & GL_ATIME) || | 1148 | if (gfs2_assert_warn(sdp, gh->gh_flags & GL_ATIME) || |
1144 | gfs2_assert_warn(sdp, !(gh->gh_flags & GL_ASYNC)) || | 1149 | gfs2_assert_warn(sdp, !(gh->gh_flags & GL_ASYNC)) || |
@@ -1156,8 +1161,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) | |||
1156 | (sdp->sd_vfs->s_flags & MS_RDONLY)) | 1161 | (sdp->sd_vfs->s_flags & MS_RDONLY)) |
1157 | return 0; | 1162 | return 0; |
1158 | 1163 | ||
1159 | curtime = get_seconds(); | 1164 | if (tv.tv_sec - ip->i_inode.i_atime.tv_sec >= quantum) { |
1160 | if (curtime - ip->i_inode.i_atime.tv_sec >= quantum) { | ||
1161 | gfs2_glock_dq(gh); | 1165 | gfs2_glock_dq(gh); |
1162 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, gh->gh_flags & ~LM_FLAG_ANY, | 1166 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, gh->gh_flags & ~LM_FLAG_ANY, |
1163 | gh); | 1167 | gh); |
@@ -1168,8 +1172,8 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) | |||
1168 | /* Verify that atime hasn't been updated while we were | 1172 | /* Verify that atime hasn't been updated while we were |
1169 | trying to get exclusive lock. */ | 1173 | trying to get exclusive lock. */ |
1170 | 1174 | ||
1171 | curtime = get_seconds(); | 1175 | tv = CURRENT_TIME; |
1172 | if (curtime - ip->i_inode.i_atime.tv_sec >= quantum) { | 1176 | if (tv.tv_sec - ip->i_inode.i_atime.tv_sec >= quantum) { |
1173 | struct buffer_head *dibh; | 1177 | struct buffer_head *dibh; |
1174 | struct gfs2_dinode *di; | 1178 | struct gfs2_dinode *di; |
1175 | 1179 | ||
@@ -1183,11 +1187,12 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) | |||
1183 | if (error) | 1187 | if (error) |
1184 | goto fail_end_trans; | 1188 | goto fail_end_trans; |
1185 | 1189 | ||
1186 | ip->i_inode.i_atime.tv_sec = curtime; | 1190 | ip->i_inode.i_atime = tv; |
1187 | 1191 | ||
1188 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 1192 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
1189 | di = (struct gfs2_dinode *)dibh->b_data; | 1193 | di = (struct gfs2_dinode *)dibh->b_data; |
1190 | di->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); | 1194 | di->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); |
1195 | di->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); | ||
1191 | brelse(dibh); | 1196 | brelse(dibh); |
1192 | 1197 | ||
1193 | gfs2_trans_end(sdp); | 1198 | gfs2_trans_end(sdp); |
@@ -1290,6 +1295,9 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) | |||
1290 | str->di_entries = cpu_to_be32(di->di_entries); | 1295 | str->di_entries = cpu_to_be32(di->di_entries); |
1291 | 1296 | ||
1292 | str->di_eattr = cpu_to_be64(di->di_eattr); | 1297 | str->di_eattr = cpu_to_be64(di->di_eattr); |
1298 | str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); | ||
1299 | str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec); | ||
1300 | str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec); | ||
1293 | } | 1301 | } |
1294 | 1302 | ||
1295 | void gfs2_dinode_print(const struct gfs2_inode *ip) | 1303 | void gfs2_dinode_print(const struct gfs2_inode *ip) |