Skip to content

Commit 93fd63c

Browse files
Guangyu SunChris Mason
authored andcommitted
Btrfs: dir_inode_operations should use btrfs_update_time also
Commit 2bc5565 (Btrfs: don't update atime on RO subvolumes) ensures that the access time of an inode is not updated when the inode lives in a read-only subvolume. However, if a directory on a read-only subvolume is accessed, the atime is updated. This results in a write operation to a read-only subvolume. I believe that access times should never be updated on read-only subvolumes. To reproduce: # mkfs.btrfs -f /dev/dm-3 (...) # mount /dev/dm-3 /mnt # btrfs subvol create /mnt/sub Create subvolume '/mnt/sub' # mkdir /mnt/sub/dir # echo "abc" > /mnt/sub/dir/file # btrfs subvol snapshot -r /mnt/sub /mnt/rosnap Create a readonly snapshot of '/mnt/sub' in '/mnt/rosnap' # stat /mnt/rosnap/dir File: `/mnt/rosnap/dir' Size: 8 Blocks: 0 IO Block: 4096 directory Device: 16h/22d Inode: 257 Links: 1 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2013-09-11 07:21:49.389157126 -0400 Modify: 2013-09-11 07:22:02.330156079 -0400 Change: 2013-09-11 07:22:02.330156079 -0400 # ls /mnt/rosnap/dir file # stat /mnt/rosnap/dir File: `/mnt/rosnap/dir' Size: 8 Blocks: 0 IO Block: 4096 directory Device: 16h/22d Inode: 257 Links: 1 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2013-09-11 07:22:56.797151670 -0400 Modify: 2013-09-11 07:22:02.330156079 -0400 Change: 2013-09-11 07:22:02.330156079 -0400 Reported-by: Koen De Wit <[email protected]> Signed-off-by: Guangyu Sun <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 5138ccc commit 93fd63c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8617,11 +8617,13 @@ static const struct inode_operations btrfs_dir_inode_operations = {
86178617
.removexattr = btrfs_removexattr,
86188618
.permission = btrfs_permission,
86198619
.get_acl = btrfs_get_acl,
8620+
.update_time = btrfs_update_time,
86208621
};
86218622
static const struct inode_operations btrfs_dir_ro_inode_operations = {
86228623
.lookup = btrfs_lookup,
86238624
.permission = btrfs_permission,
86248625
.get_acl = btrfs_get_acl,
8626+
.update_time = btrfs_update_time,
86258627
};
86268628

86278629
static const struct file_operations btrfs_dir_file_operations = {

0 commit comments

Comments
 (0)