aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorTiger Yang <tiger.yang@oracle.com>2006-11-15 02:49:02 -0500
committerMark Fasheh <mark.fasheh@oracle.com>2006-12-01 21:28:58 -0500
commit25899deef46c226c49c53b42c00e0f032379c04b (patch)
treeac8c19482ab05ee2e13d874eecd8b2eaa507a156 /fs/ocfs2
parent7f1a37e31f94b4f1c123d32ce9f69205ab2095bd (diff)
ocfs2: update file system paths to set atime
Conditionally update atime in ocfs2_file_aio_read(), ocfs2_readdir() and ocfs2_mmap(). Signed-off-by: Tiger Yang <tiger.yang@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/dir.c13
-rw-r--r--fs/ocfs2/file.c6
-rw-r--r--fs/ocfs2/mmap.c11
-rw-r--r--fs/ocfs2/symlink.c4
4 files changed, 28 insertions, 6 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 5efea44d780..baad2aa27c1 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -82,6 +82,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
82 struct inode *inode = filp->f_dentry->d_inode; 82 struct inode *inode = filp->f_dentry->d_inode;
83 struct super_block * sb = inode->i_sb; 83 struct super_block * sb = inode->i_sb;
84 unsigned int ra_sectors = 16; 84 unsigned int ra_sectors = 16;
85 int lock_level = 0;
85 86
86 mlog_entry("dirino=%llu\n", 87 mlog_entry("dirino=%llu\n",
87 (unsigned long long)OCFS2_I(inode)->ip_blkno); 88 (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -89,7 +90,15 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
89 stored = 0; 90 stored = 0;
90 bh = NULL; 91 bh = NULL;
91 92
92 error = ocfs2_meta_lock(inode, NULL, 0); 93 error = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level);
94 if (lock_level && error >= 0) {
95 /* We release EX lock which used to update atime
96 * and get PR lock again to reduce contention
97 * on commonly accessed directories. */
98 ocfs2_meta_unlock(inode, 1);
99 lock_level = 0;
100 error = ocfs2_meta_lock(inode, NULL, 0);
101 }
93 if (error < 0) { 102 if (error < 0) {
94 if (error != -ENOENT) 103 if (error != -ENOENT)
95 mlog_errno(error); 104 mlog_errno(error);
@@ -198,7 +207,7 @@ revalidate:
198 207
199 stored = 0; 208 stored = 0;
200bail: 209bail:
201 ocfs2_meta_unlock(inode, 0); 210 ocfs2_meta_unlock(inode, lock_level);
202 211
203bail_nolock: 212bail_nolock:
204 mlog_exit(stored); 213 mlog_exit(stored);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index e82288f7cf2..b64ef7c6e2d 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1254,7 +1254,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
1254 unsigned long nr_segs, 1254 unsigned long nr_segs,
1255 loff_t pos) 1255 loff_t pos)
1256{ 1256{
1257 int ret = 0, rw_level = -1, have_alloc_sem = 0; 1257 int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0;
1258 struct file *filp = iocb->ki_filp; 1258 struct file *filp = iocb->ki_filp;
1259 struct inode *inode = filp->f_dentry->d_inode; 1259 struct inode *inode = filp->f_dentry->d_inode;
1260 1260
@@ -1296,12 +1296,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
1296 * like i_size. This allows the checks down below 1296 * like i_size. This allows the checks down below
1297 * generic_file_aio_read() a chance of actually working. 1297 * generic_file_aio_read() a chance of actually working.
1298 */ 1298 */
1299 ret = ocfs2_meta_lock(inode, NULL, 0); 1299 ret = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level);
1300 if (ret < 0) { 1300 if (ret < 0) {
1301 mlog_errno(ret); 1301 mlog_errno(ret);
1302 goto bail; 1302 goto bail;
1303 } 1303 }
1304 ocfs2_meta_unlock(inode, 0); 1304 ocfs2_meta_unlock(inode, lock_level);
1305 1305
1306 ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); 1306 ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos);
1307 if (ret == -EINVAL) 1307 if (ret == -EINVAL)
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index 83934e33e5b..69f85ae392d 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -82,6 +82,8 @@ static struct vm_operations_struct ocfs2_file_vm_ops = {
82 82
83int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) 83int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
84{ 84{
85 int ret = 0, lock_level = 0;
86
85 /* We don't want to support shared writable mappings yet. */ 87 /* We don't want to support shared writable mappings yet. */
86 if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) 88 if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE))
87 && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { 89 && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) {
@@ -91,7 +93,14 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
91 return -EINVAL; 93 return -EINVAL;
92 } 94 }
93 95
94 file_accessed(file); 96 ret = ocfs2_meta_lock_atime(file->f_dentry->d_inode,
97 file->f_vfsmnt, &lock_level);
98 if (ret < 0) {
99 mlog_errno(ret);
100 goto out;
101 }
102 ocfs2_meta_unlock(file->f_dentry->d_inode, lock_level);
103out:
95 vma->vm_ops = &ocfs2_file_vm_ops; 104 vma->vm_ops = &ocfs2_file_vm_ops;
96 return 0; 105 return 0;
97} 106}
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index c0f68aa6c17..957d6878b03 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -126,6 +126,10 @@ static int ocfs2_readlink(struct dentry *dentry,
126 goto out; 126 goto out;
127 } 127 }
128 128
129 /*
130 * Without vfsmount we can't update atime now,
131 * but we will update atime here ultimately.
132 */
129 ret = vfs_readlink(dentry, buffer, buflen, link); 133 ret = vfs_readlink(dentry, buffer, buflen, link);
130 134
131 brelse(bh); 135 brelse(bh);