Commit 93fd63c2 authored by Guangyu Sun's avatar Guangyu Sun Committed by Chris Mason

Btrfs: dir_inode_operations should use btrfs_update_time also

Commit 2bc55652 (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: default avatarKoen De Wit <koen.de.wit@oracle.com>
Signed-off-by: default avatarGuangyu Sun <guangyu.sun@oracle.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 5138cccf
...@@ -8617,11 +8617,13 @@ static const struct inode_operations btrfs_dir_inode_operations = { ...@@ -8617,11 +8617,13 @@ static const struct inode_operations btrfs_dir_inode_operations = {
.removexattr = btrfs_removexattr, .removexattr = btrfs_removexattr,
.permission = btrfs_permission, .permission = btrfs_permission,
.get_acl = btrfs_get_acl, .get_acl = btrfs_get_acl,
.update_time = btrfs_update_time,
}; };
static const struct inode_operations btrfs_dir_ro_inode_operations = { static const struct inode_operations btrfs_dir_ro_inode_operations = {
.lookup = btrfs_lookup, .lookup = btrfs_lookup,
.permission = btrfs_permission, .permission = btrfs_permission,
.get_acl = btrfs_get_acl, .get_acl = btrfs_get_acl,
.update_time = btrfs_update_time,
}; };
static const struct file_operations btrfs_dir_file_operations = { static const struct file_operations btrfs_dir_file_operations = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment