]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] add file_accessed() helper
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Thu, 18 Mar 2004 13:38:53 +0000 (05:38 -0800)
committerDavid S. Miller <davem@nuts.davemloft.net>
Thu, 18 Mar 2004 13:38:53 +0000 (05:38 -0800)
New inlined helper - file_accessed(file) (wrapper for update_atime())

drivers/char/random.c
fs/coda/dir.c
fs/hugetlbfs/inode.c
fs/pipe.c
fs/readdir.c
include/linux/fs.h
ipc/shm.c
mm/filemap.c
mm/shmem.c

index 84a7fd56bea195f072f8d86cc28853dac170915e..117f195029a1e55349bfa31839f2ab0668ec95c2 100644 (file)
@@ -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);
 }
index 321024863919ce0e9cefff2cdeabd956a9950c77..2fe494a3d0b3bee17a95b3672990a6a69ec2ada6 100644 (file)
@@ -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:
index ef3a749225e0148dfa61631209edd94266f8c7a8..c60d937b202e0d9ef1ec198205a72b2f4367bee7 100644 (file)
@@ -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);
index 1aa305842a3f748502639e49db8a9c629ae5acc9..737271c0c9b9e7f36c69932cdb539c5a4602110a 100644 (file)
--- 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;
 }
 
index 7104275d457a364c2099696252355dd3adc3127b..9d89f0ab9d2bbd4623681b92fda5cfd193788964 100644 (file)
@@ -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:
index 9468e5d98eadc83b31442576b4c9a80309a71bc6..c069102db20740ebd6093155289f19cb33699e20 100644 (file)
@@ -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);
index 9721b42ec9d87c739ddb553cb4ee1acebe722c8c..4897cfe16f27830339052763fe269f79612aff05 100644 (file)
--- 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;
index 66200a89442ff57e336c07397dc83d324f9670b4..83d4ece4945e3af975504aa3843d3f8e55272dee 100644 (file)
@@ -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;
 }
index 9eee85b3f756ccaa58af1fcc3e80a44aa821a37a..85f3e5025e0796949f0dfba34d581d13d7557a7c 100644 (file)
@@ -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)