[PATCH] relative atime

Add "relatime" (relative atime) support.  Relative atime only updates the
atime if the previous atime is older than the mtime or ctime.  Like
noatime, but useful for applications like mutt that need to know when a
file has been read since it was last modified.

A corresponding patch against mount(8) is available at
http://userweb.kernel.org/~akpm/mount-relative-atime.txt

Signed-off-by: Valerie Henson <val_henson@linux.intel.com>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Valerie Henson 2006-12-13 00:34:34 -08:00 committed by Linus Torvalds
parent b227613841
commit 47ae32d6a5
4 changed files with 24 additions and 5 deletions

View file

@ -1177,13 +1177,27 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
return; return;
if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
return; return;
if (mnt->mnt_flags & MNT_RELATIME) {
/*
* With relative atime, only update atime if the
* previous atime is earlier than either the ctime or
* mtime.
*/
if (timespec_compare(&inode->i_mtime,
&inode->i_atime) < 0 &&
timespec_compare(&inode->i_ctime,
&inode->i_atime) < 0)
return;
}
} }
now = current_fs_time(inode->i_sb); now = current_fs_time(inode->i_sb);
if (!timespec_equal(&inode->i_atime, &now)) { if (timespec_equal(&inode->i_atime, &now))
inode->i_atime = now; return;
mark_inode_dirty_sync(inode);
} inode->i_atime = now;
mark_inode_dirty_sync(inode);
} }
EXPORT_SYMBOL(touch_atime); EXPORT_SYMBOL(touch_atime);

View file

@ -368,6 +368,7 @@ static int show_vfsmnt(struct seq_file *m, void *v)
{ MNT_NOEXEC, ",noexec" }, { MNT_NOEXEC, ",noexec" },
{ MNT_NOATIME, ",noatime" }, { MNT_NOATIME, ",noatime" },
{ MNT_NODIRATIME, ",nodiratime" }, { MNT_NODIRATIME, ",nodiratime" },
{ MNT_RELATIME, ",relatime" },
{ 0, NULL } { 0, NULL }
}; };
struct proc_fs_info *fs_infop; struct proc_fs_info *fs_infop;
@ -1405,9 +1406,11 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
mnt_flags |= MNT_NOATIME; mnt_flags |= MNT_NOATIME;
if (flags & MS_NODIRATIME) if (flags & MS_NODIRATIME)
mnt_flags |= MNT_NODIRATIME; mnt_flags |= MNT_NODIRATIME;
if (flags & MS_RELATIME)
mnt_flags |= MNT_RELATIME;
flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
MS_NOATIME | MS_NODIRATIME); MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
/* ... and get the mountpoint */ /* ... and get the mountpoint */
retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd); retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);

View file

@ -120,6 +120,7 @@ extern int dir_notify_enable;
#define MS_PRIVATE (1<<18) /* change to private */ #define MS_PRIVATE (1<<18) /* change to private */
#define MS_SLAVE (1<<19) /* change to slave */ #define MS_SLAVE (1<<19) /* change to slave */
#define MS_SHARED (1<<20) /* change to shared */ #define MS_SHARED (1<<20) /* change to shared */
#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
#define MS_ACTIVE (1<<30) #define MS_ACTIVE (1<<30)
#define MS_NOUSER (1<<31) #define MS_NOUSER (1<<31)

View file

@ -27,6 +27,7 @@ struct mnt_namespace;
#define MNT_NOEXEC 0x04 #define MNT_NOEXEC 0x04
#define MNT_NOATIME 0x08 #define MNT_NOATIME 0x08
#define MNT_NODIRATIME 0x10 #define MNT_NODIRATIME 0x10
#define MNT_RELATIME 0x20
#define MNT_SHRINKABLE 0x100 #define MNT_SHRINKABLE 0x100