diff options
author | Tiger Yang <tiger.yang@oracle.com> | 2006-11-15 02:48:42 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2006-12-01 21:28:51 -0500 |
commit | 7f1a37e31f94b4f1c123d32ce9f69205ab2095bd (patch) | |
tree | 7d2136573966de80d031e7320db11c15d7f93a92 /fs/ocfs2/file.c | |
parent | 8659ac25b434fcc61cf7797f4b69edc3eaaffb55 (diff) |
ocfs2: core atime update functions
This patch adds the core routines for updating atime in ocfs2.
Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r-- | fs/ocfs2/file.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index b32cdb3bf7c5..e82288f7cf21 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/uio.h> | 32 | #include <linux/uio.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/pipe_fs_i.h> | 34 | #include <linux/pipe_fs_i.h> |
35 | #include <linux/mount.h> | ||
35 | 36 | ||
36 | #define MLOG_MASK_PREFIX ML_INODE | 37 | #define MLOG_MASK_PREFIX ML_INODE |
37 | #include <cluster/masklog.h> | 38 | #include <cluster/masklog.h> |
@@ -135,6 +136,57 @@ bail: | |||
135 | return (err < 0) ? -EIO : 0; | 136 | return (err < 0) ? -EIO : 0; |
136 | } | 137 | } |
137 | 138 | ||
139 | int ocfs2_should_update_atime(struct inode *inode, | ||
140 | struct vfsmount *vfsmnt) | ||
141 | { | ||
142 | struct timespec now; | ||
143 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
144 | |||
145 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) | ||
146 | return 0; | ||
147 | |||
148 | if ((inode->i_flags & S_NOATIME) || | ||
149 | ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))) | ||
150 | return 0; | ||
151 | |||
152 | if ((vfsmnt->mnt_flags & MNT_NOATIME) || | ||
153 | ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))) | ||
154 | return 0; | ||
155 | |||
156 | now = CURRENT_TIME; | ||
157 | if ((now.tv_sec - inode->i_atime.tv_sec <= osb->s_atime_quantum)) | ||
158 | return 0; | ||
159 | else | ||
160 | return 1; | ||
161 | } | ||
162 | |||
163 | int ocfs2_update_inode_atime(struct inode *inode, | ||
164 | struct buffer_head *bh) | ||
165 | { | ||
166 | int ret; | ||
167 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
168 | handle_t *handle; | ||
169 | |||
170 | mlog_entry_void(); | ||
171 | |||
172 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | ||
173 | if (handle == NULL) { | ||
174 | ret = -ENOMEM; | ||
175 | mlog_errno(ret); | ||
176 | goto out; | ||
177 | } | ||
178 | |||
179 | inode->i_atime = CURRENT_TIME; | ||
180 | ret = ocfs2_mark_inode_dirty(handle, inode, bh); | ||
181 | if (ret < 0) | ||
182 | mlog_errno(ret); | ||
183 | |||
184 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | ||
185 | out: | ||
186 | mlog_exit(ret); | ||
187 | return ret; | ||
188 | } | ||
189 | |||
138 | int ocfs2_set_inode_size(handle_t *handle, | 190 | int ocfs2_set_inode_size(handle_t *handle, |
139 | struct inode *inode, | 191 | struct inode *inode, |
140 | struct buffer_head *fe_bh, | 192 | struct buffer_head *fe_bh, |