[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:
committed by
Linus Torvalds
parent
b227613841
commit
47ae32d6a5
22
fs/inode.c
22
fs/inode.c
@@ -1177,13 +1177,27 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
|
||||
return;
|
||||
if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
|
||||
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);
|
||||
if (!timespec_equal(&inode->i_atime, &now)) {
|
||||
inode->i_atime = now;
|
||||
mark_inode_dirty_sync(inode);
|
||||
}
|
||||
if (timespec_equal(&inode->i_atime, &now))
|
||||
return;
|
||||
|
||||
inode->i_atime = now;
|
||||
mark_inode_dirty_sync(inode);
|
||||
}
|
||||
EXPORT_SYMBOL(touch_atime);
|
||||
|
||||
|
Reference in New Issue
Block a user