]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
xfs: update ctime and mtime on clone destinatation inodes
authorChristoph Hellwig <hch@lst.de>
Tue, 7 Feb 2017 01:45:51 +0000 (17:45 -0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 21 Apr 2017 08:11:16 +0000 (10:11 +0200)
BugLink: http://bugs.launchpad.net/bugs/1681875
commit c5ecb42342852892f978572ddc6dca703460f25a upstream.

We're changing both metadata and data, so we need to update the
timestamps for clone operations.  Dedupe on the other hand does
not change file data, and only changes invisible metadata so the
timestamps should not be updated.

This follows existing btrfs behavior.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: remove redundant is_dedupe test]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
fs/xfs/xfs_reflink.c

index 8c8c4f4676da4e70d829dabf735cac7086308c59..d8c51248e2072911f7150a1abb9f4d2659217bb0 100644 (file)
@@ -955,13 +955,14 @@ STATIC int
 xfs_reflink_update_dest(
        struct xfs_inode        *dest,
        xfs_off_t               newlen,
-       xfs_extlen_t            cowextsize)
+       xfs_extlen_t            cowextsize,
+       bool                    is_dedupe)
 {
        struct xfs_mount        *mp = dest->i_mount;
        struct xfs_trans        *tp;
        int                     error;
 
-       if (newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0)
+       if (is_dedupe && newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0)
                return 0;
 
        error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);
@@ -982,6 +983,10 @@ xfs_reflink_update_dest(
                dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
        }
 
+       if (!is_dedupe) {
+               xfs_trans_ichgtime(tp, dest,
+                                  XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
+       }
        xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE);
 
        error = xfs_trans_commit(tp);
@@ -1295,7 +1300,8 @@ xfs_reflink_remap_range(
            !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE))
                cowextsize = src->i_d.di_cowextsize;
 
-       ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize);
+       ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize,
+                       is_dedupe);
 
 out_unlock:
        xfs_iunlock(src, XFS_MMAPLOCK_EXCL);