diff options
| author | Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2004-03-18 05:38:53 -0800 |
|---|---|---|
| committer | David S. Miller <davem@nuts.davemloft.net> | 2004-03-18 05:38:53 -0800 |
| commit | 5f9861a66ce697389ea89236902ef6ef5f54225b (patch) | |
| tree | 06e9241e8dfe5f77aa50ae7cb0685651bf3e3505 | |
| parent | d2a4a177a25de3099c2a6bb0272211728261228d (diff) | |
[PATCH] add file_accessed() helper
New inlined helper - file_accessed(file) (wrapper for update_atime())
| -rw-r--r-- | drivers/char/random.c | 5 | ||||
| -rw-r--r-- | fs/coda/dir.c | 2 | ||||
| -rw-r--r-- | fs/hugetlbfs/inode.c | 2 | ||||
| -rw-r--r-- | fs/pipe.c | 2 | ||||
| -rw-r--r-- | fs/readdir.c | 2 | ||||
| -rw-r--r-- | include/linux/fs.h | 8 | ||||
| -rw-r--r-- | ipc/shm.c | 2 | ||||
| -rw-r--r-- | mm/filemap.c | 7 | ||||
| -rw-r--r-- | mm/shmem.c | 12 |
9 files changed, 20 insertions, 22 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 84a7fd56bea1..117f195029a1 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -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); } diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 321024863919..2fe494a3d0b3 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -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: diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index ef3a749225e0..c60d937b202e 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -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); diff --git a/fs/pipe.c b/fs/pipe.c index 1aa305842a3f..737271c0c9b9 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -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; } diff --git a/fs/readdir.c b/fs/readdir.c index 7104275d457a..9d89f0ab9d2b 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -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: diff --git a/include/linux/fs.h b/include/linux/fs.h index 9468e5d98ead..c069102db207 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -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); diff --git a/ipc/shm.c b/ipc/shm.c index 9721b42ec9d8..4897cfe16f27 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -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; diff --git a/mm/filemap.c b/mm/filemap.c index 66200a89442f..83d4ece4945e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -725,7 +725,7 @@ no_cached_page: *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; } diff --git a/mm/shmem.c b/mm/shmem.c index 9eee85b3f756..85f3e5025e07 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -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) |
