Btrfs: don't update atime on RO subvolumes
Subsystems (2)
PATCH 1/1 Btrfs: don't update atime on RO subvolumes
Before the update_time inode operation was indroduced, it was not possible to prevent updates of atime on RO subvolumes. btrfs_update_time does now check if the root is RO and skip updating of atime.
This patch requires the update_time patches from Josef Bacik.
Signed-off-by Alexander Block <[email protected]>
--- fs/btrfs/inode.c | 26 +++++++++++++++++++++----- fs/inode.c | 3 +++ 2 files changed, 24 insertions(+), 5 deletions(-)
fs/btrfs/inode.c +21 -5
@@ -4470,14 +4470,30 @@ int btrfs_dirty_inode(struct inode *inode)static int btrfs_update_time (struct inode *inode,struct timespec *now,int flags) { -if (flags &S_VERSION ) +struct btrfs_root *root =BTRFS_I (inode)->root; +int did_update =0 ; + +if (flags &S_VERSION ) {inode_inc_iversion (inode); -if (flags &S_CTIME ) + did_update =1 ; + } +if (flags &S_CTIME ) { inode->i_ctime = *now; -if (flags &S_MTIME ) + did_update =1 ; + } +if (flags &S_MTIME ) { inode->i_mtime = *now; -if (flags &S_ATIME ) - inode->i_atime = *now; + did_update =1 ; + } +if (flags &S_ATIME ) { +/* don't do atime updates on RO subvolumes */ +if (!btrfs_root_readonly (root)) { + inode->i_atime = *now; + did_update =1 ; + } + } +if (!did_update) +return 0 ;return btrfs_dirty_inode (inode); }
fs/inode.c +3 -0
@@ -1545,6 +1545,9 @@ void touch_atime(struct path *path)* Btrfs), but since we touch atime while walking down the path we * really don't care if we failed to update the atime of the file, * so just ignore the return value. +* Also, the checks done above to see if updating atime is allowed +* are not enough for some filesystems. Btrfs for example may have +* RO subvolumes on a RW filesystems, which vfs is not aware of. */ update_time (inode, &now,S_ATIME );mnt_drop_write (mnt);
Signature · 1 line
1.7.10