Skip to content

Commit 2bc5565

Browse files
Alexander BlockChris Mason
authored andcommitted
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. VFS was only able to check for RO on the mount, but did not know anything about btrfs subvolumes. btrfs_update_time does now check if the root is RO and skip updating of times. Signed-off-by: Alexander Block <[email protected]>
1 parent 063849e commit 2bc5565

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

fs/btrfs/inode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4518,6 +4518,11 @@ int btrfs_dirty_inode(struct inode *inode)
45184518
static int btrfs_update_time(struct inode *inode, struct timespec *now,
45194519
int flags)
45204520
{
4521+
struct btrfs_root *root = BTRFS_I(inode)->root;
4522+
4523+
if (btrfs_root_readonly(root))
4524+
return -EROFS;
4525+
45214526
if (flags & S_VERSION)
45224527
inode_inc_iversion(inode);
45234528
if (flags & S_CTIME)

fs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,8 @@ void touch_atime(struct path *path)
15511551
* Btrfs), but since we touch atime while walking down the path we
15521552
* really don't care if we failed to update the atime of the file,
15531553
* so just ignore the return value.
1554+
* We may also fail on filesystems that have the ability to make parts
1555+
* of the fs read only, e.g. subvolumes in Btrfs.
15541556
*/
15551557
update_time(inode, &now, S_ATIME);
15561558
mnt_drop_write(mnt);

0 commit comments

Comments
 (0)