]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: only dirty the inode in btrfs_update_time if something was changed
authorJeff Layton <jlayton@redhat.com>
Mon, 11 Dec 2017 11:35:24 +0000 (06:35 -0500)
committerJeff Layton <jlayton@redhat.com>
Mon, 29 Jan 2018 11:42:21 +0000 (06:42 -0500)
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>
fs/btrfs/inode.c

index ac8692849a81fcde3dc86c1ca281d06d59e62cb5..76245323a7c8abed0db0280fe775fdb7694cb53e 100644 (file)
@@ -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;
 }
 
 /*