Commit 5f9861a6 authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[PATCH] add file_accessed() helper

New inlined helper - file_accessed(file) (wrapper for update_atime())
parent d2a4a177
......@@ -1640,9 +1640,8 @@ random_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
/*
* If we gave the user some bytes, update the access time.
*/
if (count != 0) {
update_atime(file->f_dentry->d_inode);
}
if (count)
file_accessed(file);
return (count ? count : retval);
}
......
......@@ -512,7 +512,7 @@ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
ret = -ENOENT;
if (!IS_DEADDIR(host_inode)) {
ret = host_file->f_op->readdir(host_file, filldir, dirent);
update_atime(host_inode);
file_accessed(host_file);
}
}
out:
......
......@@ -62,7 +62,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
vma_len = (loff_t)(vma->vm_end - vma->vm_start);
down(&inode->i_sem);
update_atime(inode);
file_accessed(file);
vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
vma->vm_ops = &hugetlb_vm_ops;
ret = hugetlb_prefault(mapping, vma);
......
......@@ -165,7 +165,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
}
if (ret > 0)
update_atime(inode);
file_accessed(filp);
return ret;
}
......
......@@ -32,7 +32,7 @@ int vfs_readdir(struct file *file, filldir_t filler, void *buf)
res = -ENOENT;
if (!IS_DEADDIR(inode)) {
res = file->f_op->readdir(file, buf, filler);
update_atime(inode);
file_accessed(file);
}
up(&inode->i_sem);
out:
......
......@@ -914,6 +914,11 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
__mark_inode_dirty(inode, I_DIRTY_SYNC);
}
static inline void file_accessed(struct file *file)
{
update_atime(file->f_dentry->d_inode);
}
/**
* &export_operations - for nfsd to communicate with file systems
......@@ -1321,7 +1326,8 @@ extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t l
ssize_t generic_file_write_nolock(struct file *file, const struct iovec *iov,
unsigned long nr_segs, loff_t *ppos);
extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void __user *);
extern void do_generic_mapping_read(struct address_space *, struct file_ra_state *, struct file *,
extern void do_generic_mapping_read(struct address_space *mapping,
struct file_ra_state *, struct file *,
loff_t *, read_descriptor_t *, read_actor_t);
extern void
file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
......
......@@ -149,7 +149,7 @@ static void shm_close (struct vm_area_struct *shmd)
static int shm_mmap(struct file * file, struct vm_area_struct * vma)
{
update_atime(file->f_dentry->d_inode);
file_accessed(file);
vma->vm_ops = &shm_vm_ops;
shm_inc(file->f_dentry->d_inode->i_ino);
return 0;
......
......@@ -725,7 +725,7 @@ void do_generic_mapping_read(struct address_space *mapping,
*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
if (cached_page)
page_cache_release(cached_page);
update_atime(inode);
file_accessed(filp);
}
EXPORT_SYMBOL(do_generic_mapping_read);
......@@ -820,7 +820,7 @@ __generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
if (retval > 0)
*ppos = pos + retval;
}
update_atime(filp->f_dentry->d_inode);
file_accessed(filp);
goto out;
}
......@@ -1353,11 +1353,10 @@ static struct vm_operations_struct generic_file_vm_ops = {
int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
{
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
if (!mapping->a_ops->readpage)
return -ENOEXEC;
update_atime(inode);
file_accessed(file);
vma->vm_ops = &generic_file_vm_ops;
return 0;
}
......
......@@ -1061,14 +1061,8 @@ void shmem_lock(struct file *file, int lock)
static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
{
struct vm_operations_struct *ops;
struct inode *inode = file->f_dentry->d_inode;
ops = &shmem_vm_ops;
if (!S_ISREG(inode->i_mode))
return -EACCES;
update_atime(inode);
vma->vm_ops = ops;
file_accessed(file);
vma->vm_ops = &shmem_vm_ops;
return 0;
}
......@@ -1363,7 +1357,7 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_
}
*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
update_atime(inode);
file_accessed(filp);
}
static ssize_t shmem_file_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment