btrfs: Replace CURRENT_TIME by current_fs_time()
authorDeepa Dinamani <deepa.kernel@gmail.com>
Sun, 7 Feb 2016 07:57:21 +0000 (23:57 -0800)
committerDavid Sterba <dsterba@suse.com>
Thu, 18 Feb 2016 10:46:03 +0000 (11:46 +0100)
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Cc: linux-btrfs@vger.kernel.org
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/root-tree.c
fs/btrfs/transaction.c
fs/btrfs/xattr.c

index 098bb8f690c992e1ebd01270f49ff2d37e6658bd..610f56992464892a085b21891c7c2cee4ec5f4f1 100644 (file)
@@ -2544,7 +2544,7 @@ out_trans:
                goto out_free;
 
        inode_inc_iversion(inode);
-       inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+       inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
 
        trans->block_rsv = &root->fs_info->trans_block_rsv;
        ret = btrfs_update_inode(trans, root, inode);
@@ -2794,7 +2794,7 @@ static long btrfs_fallocate(struct file *file, int mode,
                if (IS_ERR(trans)) {
                        ret = PTR_ERR(trans);
                } else {
-                       inode->i_ctime = CURRENT_TIME;
+                       inode->i_ctime = current_fs_time(inode->i_sb);
                        i_size_write(inode, actual_end);
                        btrfs_ordered_update_i_size(inode, actual_end, NULL);
                        ret = btrfs_update_inode(trans, root, inode);
index 5f06eb1f43843055c0373daeb9ad98648865150f..cf0b3795364aab33ea0439263d5099fd081cc1eb 100644 (file)
@@ -4013,7 +4013,8 @@ err:
        btrfs_i_size_write(dir, dir->i_size - name_len * 2);
        inode_inc_iversion(inode);
        inode_inc_iversion(dir);
-       inode->i_ctime = dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+       inode->i_ctime = dir->i_mtime =
+               dir->i_ctime = current_fs_time(inode->i_sb);
        ret = btrfs_update_inode(trans, root, dir);
 out:
        return ret;
@@ -4156,7 +4157,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 
        btrfs_i_size_write(dir, dir->i_size - name_len * 2);
        inode_inc_iversion(dir);
-       dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+       dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
        ret = btrfs_update_inode_fallback(trans, root, dir);
        if (ret)
                btrfs_abort_transaction(trans, root, ret);
@@ -5588,7 +5589,7 @@ static struct inode *new_simple_dir(struct super_block *s,
        inode->i_op = &btrfs_dir_ro_inode_operations;
        inode->i_fop = &simple_dir_operations;
        inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
-       inode->i_mtime = CURRENT_TIME;
+       inode->i_mtime = current_fs_time(inode->i_sb);
        inode->i_atime = inode->i_mtime;
        inode->i_ctime = inode->i_mtime;
        BTRFS_I(inode)->i_otime = inode->i_mtime;
@@ -6160,7 +6161,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
        inode_init_owner(inode, dir, mode);
        inode_set_bytes(inode, 0);
 
-       inode->i_mtime = CURRENT_TIME;
+       inode->i_mtime = current_fs_time(inode->i_sb);
        inode->i_atime = inode->i_mtime;
        inode->i_ctime = inode->i_mtime;
        BTRFS_I(inode)->i_otime = inode->i_mtime;
@@ -6273,7 +6274,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
        btrfs_i_size_write(parent_inode, parent_inode->i_size +
                           name_len * 2);
        inode_inc_iversion(parent_inode);
-       parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
+       parent_inode->i_mtime = parent_inode->i_ctime =
+               current_fs_time(parent_inode->i_sb);
        ret = btrfs_update_inode(trans, root, parent_inode);
        if (ret)
                btrfs_abort_transaction(trans, root, ret);
@@ -6491,7 +6493,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
        BTRFS_I(inode)->dir_index = 0ULL;
        inc_nlink(inode);
        inode_inc_iversion(inode);
-       inode->i_ctime = CURRENT_TIME;
+       inode->i_ctime = current_fs_time(inode->i_sb);
        ihold(inode);
        set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
 
@@ -9254,7 +9256,6 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct btrfs_root *dest = BTRFS_I(new_dir)->root;
        struct inode *new_inode = d_inode(new_dentry);
        struct inode *old_inode = d_inode(old_dentry);
-       struct timespec ctime = CURRENT_TIME;
        u64 index = 0;
        u64 root_objectid;
        int ret;
@@ -9351,9 +9352,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        inode_inc_iversion(old_dir);
        inode_inc_iversion(new_dir);
        inode_inc_iversion(old_inode);
-       old_dir->i_ctime = old_dir->i_mtime = ctime;
-       new_dir->i_ctime = new_dir->i_mtime = ctime;
-       old_inode->i_ctime = ctime;
+       old_dir->i_ctime = old_dir->i_mtime =
+       new_dir->i_ctime = new_dir->i_mtime =
+       old_inode->i_ctime = current_fs_time(old_dir->i_sb);
 
        if (old_dentry->d_parent != new_dentry->d_parent)
                btrfs_record_unlink_dir(trans, old_dir, old_inode, 1);
@@ -9378,7 +9379,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
        if (new_inode) {
                inode_inc_iversion(new_inode);
-               new_inode->i_ctime = CURRENT_TIME;
+               new_inode->i_ctime = current_fs_time(new_inode->i_sb);
                if (unlikely(btrfs_ino(new_inode) ==
                             BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
                        root_objectid = BTRFS_I(new_inode)->location.objectid;
@@ -9856,7 +9857,7 @@ next:
                *alloc_hint = ins.objectid + ins.offset;
 
                inode_inc_iversion(inode);
-               inode->i_ctime = CURRENT_TIME;
+               inode->i_ctime = current_fs_time(inode->i_sb);
                BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
                if (!(mode & FALLOC_FL_KEEP_SIZE) &&
                    (actual_len > inode->i_size) &&
index e65fdc8550b14687d1cc5b7f07e04d49999b76b0..0cdcdf216a1bb2935e9faf3ec831f27fdfe42104 100644 (file)
@@ -347,7 +347,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 
        btrfs_update_iflags(inode);
        inode_inc_iversion(inode);
-       inode->i_ctime = CURRENT_TIME;
+       inode->i_ctime = current_fs_time(inode->i_sb);
        ret = btrfs_update_inode(trans, root, inode);
 
        btrfs_end_transaction(trans, root);
@@ -443,7 +443,7 @@ static noinline int create_subvol(struct inode *dir,
        struct btrfs_root *root = BTRFS_I(dir)->root;
        struct btrfs_root *new_root;
        struct btrfs_block_rsv block_rsv;
-       struct timespec cur_time = CURRENT_TIME;
+       struct timespec cur_time = current_fs_time(dir->i_sb);
        struct inode *inode;
        int ret;
        int err;
@@ -3144,7 +3144,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
 
        inode_inc_iversion(inode);
        if (!no_time_update)
-               inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+               inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
        /*
         * We round up to the block size at eof when determining which
         * extents to clone above, but shouldn't round up the file size.
@@ -4952,7 +4952,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_root_item *root_item = &root->root_item;
        struct btrfs_trans_handle *trans;
-       struct timespec ct = CURRENT_TIME;
+       struct timespec ct = current_fs_time(inode->i_sb);
        int ret = 0;
        int received_uuid_changed;
 
index 7cf8509deda7c0ea6e98af02a8ab0acafbe016b2..a25f3b21491b809b1937408d092b443d4e4550e5 100644 (file)
@@ -488,7 +488,7 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root)
 {
        struct btrfs_root_item *item = &root->root_item;
-       struct timespec ct = CURRENT_TIME;
+       struct timespec ct = current_fs_time(root->fs_info->sb);
 
        spin_lock(&root->root_item_lock);
        btrfs_set_root_ctransid(item, trans->transid);
index b6031ce474f7c06f90c764c0bf520a95480ef561..37562d614abc2beb99282805ae17cc1d8bbec7fd 100644 (file)
@@ -1333,7 +1333,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        struct dentry *dentry;
        struct extent_buffer *tmp;
        struct extent_buffer *old;
-       struct timespec cur_time = CURRENT_TIME;
+       struct timespec cur_time;
        int ret = 0;
        u64 to_reserve = 0;
        u64 index = 0;
@@ -1381,6 +1381,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        parent_root = BTRFS_I(parent_inode)->root;
        record_root_in_trans(trans, parent_root);
 
+       cur_time = current_fs_time(parent_inode->i_sb);
+
        /*
         * insert the directory item
         */
@@ -1523,7 +1525,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 
        btrfs_i_size_write(parent_inode, parent_inode->i_size +
                                         dentry->d_name.len * 2);
-       parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
+       parent_inode->i_mtime = parent_inode->i_ctime =
+               current_fs_time(parent_inode->i_sb);
        ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode);
        if (ret) {
                btrfs_abort_transaction(trans, root, ret);
index 6c68d6356197afb630443f383100894227b07e65..f2a20d52b9db97ef45b39bc3672a9a38d3dc1c1c 100644 (file)
@@ -249,7 +249,7 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans,
                goto out;
 
        inode_inc_iversion(inode);
-       inode->i_ctime = CURRENT_TIME;
+       inode->i_ctime = current_fs_time(inode->i_sb);
        set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
        ret = btrfs_update_inode(trans, root, inode);
        BUG_ON(ret);