mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 14:44:12 +00:00
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>
This commit is contained in:
parent
7f1a37e31f
commit
25899deef4
4 changed files with 28 additions and 6 deletions
|
@ -82,6 +82,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
|
||||||
struct inode *inode = filp->f_dentry->d_inode;
|
struct inode *inode = filp->f_dentry->d_inode;
|
||||||
struct super_block * sb = inode->i_sb;
|
struct super_block * sb = inode->i_sb;
|
||||||
unsigned int ra_sectors = 16;
|
unsigned int ra_sectors = 16;
|
||||||
|
int lock_level = 0;
|
||||||
|
|
||||||
mlog_entry("dirino=%llu\n",
|
mlog_entry("dirino=%llu\n",
|
||||||
(unsigned long long)OCFS2_I(inode)->ip_blkno);
|
(unsigned long long)OCFS2_I(inode)->ip_blkno);
|
||||||
|
@ -89,7 +90,15 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
|
||||||
stored = 0;
|
stored = 0;
|
||||||
bh = NULL;
|
bh = NULL;
|
||||||
|
|
||||||
error = ocfs2_meta_lock(inode, NULL, 0);
|
error = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level);
|
||||||
|
if (lock_level && error >= 0) {
|
||||||
|
/* We release EX lock which used to update atime
|
||||||
|
* and get PR lock again to reduce contention
|
||||||
|
* on commonly accessed directories. */
|
||||||
|
ocfs2_meta_unlock(inode, 1);
|
||||||
|
lock_level = 0;
|
||||||
|
error = ocfs2_meta_lock(inode, NULL, 0);
|
||||||
|
}
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
if (error != -ENOENT)
|
if (error != -ENOENT)
|
||||||
mlog_errno(error);
|
mlog_errno(error);
|
||||||
|
@ -198,7 +207,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
|
||||||
|
|
||||||
stored = 0;
|
stored = 0;
|
||||||
bail:
|
bail:
|
||||||
ocfs2_meta_unlock(inode, 0);
|
ocfs2_meta_unlock(inode, lock_level);
|
||||||
|
|
||||||
bail_nolock:
|
bail_nolock:
|
||||||
mlog_exit(stored);
|
mlog_exit(stored);
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
|
||||||
unsigned long nr_segs,
|
unsigned long nr_segs,
|
||||||
loff_t pos)
|
loff_t pos)
|
||||||
{
|
{
|
||||||
int ret = 0, rw_level = -1, have_alloc_sem = 0;
|
int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0;
|
||||||
struct file *filp = iocb->ki_filp;
|
struct file *filp = iocb->ki_filp;
|
||||||
struct inode *inode = filp->f_dentry->d_inode;
|
struct inode *inode = filp->f_dentry->d_inode;
|
||||||
|
|
||||||
|
@ -1296,12 +1296,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
|
||||||
* like i_size. This allows the checks down below
|
* like i_size. This allows the checks down below
|
||||||
* generic_file_aio_read() a chance of actually working.
|
* generic_file_aio_read() a chance of actually working.
|
||||||
*/
|
*/
|
||||||
ret = ocfs2_meta_lock(inode, NULL, 0);
|
ret = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mlog_errno(ret);
|
mlog_errno(ret);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
ocfs2_meta_unlock(inode, 0);
|
ocfs2_meta_unlock(inode, lock_level);
|
||||||
|
|
||||||
ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos);
|
ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos);
|
||||||
if (ret == -EINVAL)
|
if (ret == -EINVAL)
|
||||||
|
|
|
@ -82,6 +82,8 @@ static struct vm_operations_struct ocfs2_file_vm_ops = {
|
||||||
|
|
||||||
int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
|
int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
|
int ret = 0, lock_level = 0;
|
||||||
|
|
||||||
/* We don't want to support shared writable mappings yet. */
|
/* We don't want to support shared writable mappings yet. */
|
||||||
if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE))
|
if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE))
|
||||||
&& ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) {
|
&& ((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)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_accessed(file);
|
ret = ocfs2_meta_lock_atime(file->f_dentry->d_inode,
|
||||||
|
file->f_vfsmnt, &lock_level);
|
||||||
|
if (ret < 0) {
|
||||||
|
mlog_errno(ret);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
ocfs2_meta_unlock(file->f_dentry->d_inode, lock_level);
|
||||||
|
out:
|
||||||
vma->vm_ops = &ocfs2_file_vm_ops;
|
vma->vm_ops = &ocfs2_file_vm_ops;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,10 @@ static int ocfs2_readlink(struct dentry *dentry,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Without vfsmount we can't update atime now,
|
||||||
|
* but we will update atime here ultimately.
|
||||||
|
*/
|
||||||
ret = vfs_readlink(dentry, buffer, buflen, link);
|
ret = vfs_readlink(dentry, buffer, buflen, link);
|
||||||
|
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
|
|
Loading…
Reference in a new issue