Skip to content

Commit

Permalink
btrfs: only dirty the inode in btrfs_update_time if something was cha…
Browse files Browse the repository at this point in the history
…nged

At this point, we know that "now" and the file times may differ, and we
suspect that the i_version has been flagged to be bumped. Attempt to
bump the i_version, and only mark the inode dirty if that actually
occurred or if one of the times was updated.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: David Sterba <dsterba@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
  • Loading branch information
Jeff Layton committed Jan 29, 2018
1 parent d17260f commit 3a8c723
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6107,19 +6107,20 @@ static int btrfs_update_time(struct inode *inode, struct timespec *now,
int flags)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
bool dirty = flags & ~S_VERSION;

if (btrfs_root_readonly(root))
return -EROFS;

if (flags & S_VERSION)
inode_inc_iversion(inode);
dirty |= inode_maybe_inc_iversion(inode, dirty);
if (flags & S_CTIME)
inode->i_ctime = *now;
if (flags & S_MTIME)
inode->i_mtime = *now;
if (flags & S_ATIME)
inode->i_atime = *now;
return btrfs_dirty_inode(inode);
return dirty ? btrfs_dirty_inode(inode) : 0;
}

/*
Expand Down

0 comments on commit 3a8c723

Please sign in to comment.