OCFS2 atime support
Tiger Yang <tiger.yang@oracle.com>
November 06, 2006
Goals
Support update/not update access time stamp when a file/directory is read in a file system with different mount options.
- atime: Update inode access time for each access. This is the default mount option.
- noatime: Do not update inode access times on this file system.
- diratime: Update directory's inode access time for each access. This is the default mount option.
- nodiratime: Do not update directory's inode access times on this file system.
Support list/change file's attribute about atime with lsattr/chattr. This is compatable with ext2.
- +A: Do not update this file's atime.
- -A: Update this file's atime.
Support setting the threshold of atime update. Because we don't want to update atime at each access so we can set a minimum period between updates with mount option atime_quantum. The default value of atime_quantum is 60 seconds.
- atime_quantum = xx: Do not update atime again in xx seconds for reduce contention.
VFS
VFS invoke file_accessed()/touch_atime() to update file's atime. Touch_atime() will check flags to determine whether or not update inode atime. Those flags are corresponding to the options.
Flags in mnt_flags of vfsmount structure.
- MNT_NOATIME: noatime
- MNT_NODIRATIME: nodiratime
Flags in i_flags of inode structure.
- S_NOATIME: chattr +A
Flags in s_flags of super_block structure.
- MS_NOATIME: indicate this file system is not support atime.
OCFS2
In ocfs2, We always set super_block->s_flags with MS_NOATIME to prevent VFS touch_atime() update ocfs2 inode atime.
We add a new API to update atime.
- int ocfs2_meta_lock_atime(struct inode *inode, struct vfsmount *vfsmnt, int *level);
{ get_PR_meta_lock(); check_flags(); if (should_update_atime) { get_EX_meta_lock(); update_atime(); } }