Merge tag 'for-5.2-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[sfrench/cifs-2.6.git] / fs / btrfs / inode.c
index 9aba9660efe56e9512b530c73a339eecbeb6b88d..a2aabdb85226d7c11eba224d6acf40d4948f307b 100644 (file)
@@ -6433,8 +6433,18 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
        btrfs_i_size_write(parent_inode, parent_inode->vfs_inode.i_size +
                           name_len * 2);
        inode_inc_iversion(&parent_inode->vfs_inode);
-       parent_inode->vfs_inode.i_mtime = parent_inode->vfs_inode.i_ctime =
-               current_time(&parent_inode->vfs_inode);
+       /*
+        * If we are replaying a log tree, we do not want to update the mtime
+        * and ctime of the parent directory with the current time, since the
+        * log replay procedure is responsible for setting them to their correct
+        * values (the ones it had when the fsync was done).
+        */
+       if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) {
+               struct timespec64 now = current_time(&parent_inode->vfs_inode);
+
+               parent_inode->vfs_inode.i_mtime = now;
+               parent_inode->vfs_inode.i_ctime = now;
+       }
        ret = btrfs_update_inode(trans, root, &parent_inode->vfs_inode);
        if (ret)
                btrfs_abort_transaction(trans, ret);