Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: Replace CURRENT_TIME by current_fs_time()

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>

authored by

Deepa Dinamani and committed by
David Sterba
04b285f3 8f682f69

+26 -22
+2 -2
fs/btrfs/file.c
··· 2544 2544 goto out_free; 2545 2545 2546 2546 inode_inc_iversion(inode); 2547 - inode->i_mtime = inode->i_ctime = CURRENT_TIME; 2547 + inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); 2548 2548 2549 2549 trans->block_rsv = &root->fs_info->trans_block_rsv; 2550 2550 ret = btrfs_update_inode(trans, root, inode); ··· 2794 2794 if (IS_ERR(trans)) { 2795 2795 ret = PTR_ERR(trans); 2796 2796 } else { 2797 - inode->i_ctime = CURRENT_TIME; 2797 + inode->i_ctime = current_fs_time(inode->i_sb); 2798 2798 i_size_write(inode, actual_end); 2799 2799 btrfs_ordered_update_i_size(inode, actual_end, NULL); 2800 2800 ret = btrfs_update_inode(trans, root, inode);
+13 -12
fs/btrfs/inode.c
··· 4013 4013 btrfs_i_size_write(dir, dir->i_size - name_len * 2); 4014 4014 inode_inc_iversion(inode); 4015 4015 inode_inc_iversion(dir); 4016 - inode->i_ctime = dir->i_mtime = dir->i_ctime = CURRENT_TIME; 4016 + inode->i_ctime = dir->i_mtime = 4017 + dir->i_ctime = current_fs_time(inode->i_sb); 4017 4018 ret = btrfs_update_inode(trans, root, dir); 4018 4019 out: 4019 4020 return ret; ··· 4157 4156 4158 4157 btrfs_i_size_write(dir, dir->i_size - name_len * 2); 4159 4158 inode_inc_iversion(dir); 4160 - dir->i_mtime = dir->i_ctime = CURRENT_TIME; 4159 + dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 4161 4160 ret = btrfs_update_inode_fallback(trans, root, dir); 4162 4161 if (ret) 4163 4162 btrfs_abort_transaction(trans, root, ret); ··· 5589 5588 inode->i_op = &btrfs_dir_ro_inode_operations; 5590 5589 inode->i_fop = &simple_dir_operations; 5591 5590 inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; 5592 - inode->i_mtime = CURRENT_TIME; 5591 + inode->i_mtime = current_fs_time(inode->i_sb); 5593 5592 inode->i_atime = inode->i_mtime; 5594 5593 inode->i_ctime = inode->i_mtime; 5595 5594 BTRFS_I(inode)->i_otime = inode->i_mtime; ··· 6161 6160 inode_init_owner(inode, dir, mode); 6162 6161 inode_set_bytes(inode, 0); 6163 6162 6164 - inode->i_mtime = CURRENT_TIME; 6163 + inode->i_mtime = current_fs_time(inode->i_sb); 6165 6164 inode->i_atime = inode->i_mtime; 6166 6165 inode->i_ctime = inode->i_mtime; 6167 6166 BTRFS_I(inode)->i_otime = inode->i_mtime; ··· 6274 6273 btrfs_i_size_write(parent_inode, parent_inode->i_size + 6275 6274 name_len * 2); 6276 6275 inode_inc_iversion(parent_inode); 6277 - parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME; 6276 + parent_inode->i_mtime = parent_inode->i_ctime = 6277 + current_fs_time(parent_inode->i_sb); 6278 6278 ret = btrfs_update_inode(trans, root, parent_inode); 6279 6279 if (ret) 6280 6280 btrfs_abort_transaction(trans, root, ret); ··· 6493 6491 BTRFS_I(inode)->dir_index = 0ULL; 6494 6492 inc_nlink(inode); 6495 6493 inode_inc_iversion(inode); 6496 - inode->i_ctime = CURRENT_TIME; 6494 + inode->i_ctime = current_fs_time(inode->i_sb); 6497 6495 ihold(inode); 6498 6496 set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags); 6499 6497 ··· 9256 9254 struct btrfs_root *dest = BTRFS_I(new_dir)->root; 9257 9255 struct inode *new_inode = d_inode(new_dentry); 9258 9256 struct inode *old_inode = d_inode(old_dentry); 9259 - struct timespec ctime = CURRENT_TIME; 9260 9257 u64 index = 0; 9261 9258 u64 root_objectid; 9262 9259 int ret; ··· 9352 9351 inode_inc_iversion(old_dir); 9353 9352 inode_inc_iversion(new_dir); 9354 9353 inode_inc_iversion(old_inode); 9355 - old_dir->i_ctime = old_dir->i_mtime = ctime; 9356 - new_dir->i_ctime = new_dir->i_mtime = ctime; 9357 - old_inode->i_ctime = ctime; 9354 + old_dir->i_ctime = old_dir->i_mtime = 9355 + new_dir->i_ctime = new_dir->i_mtime = 9356 + old_inode->i_ctime = current_fs_time(old_dir->i_sb); 9358 9357 9359 9358 if (old_dentry->d_parent != new_dentry->d_parent) 9360 9359 btrfs_record_unlink_dir(trans, old_dir, old_inode, 1); ··· 9379 9378 9380 9379 if (new_inode) { 9381 9380 inode_inc_iversion(new_inode); 9382 - new_inode->i_ctime = CURRENT_TIME; 9381 + new_inode->i_ctime = current_fs_time(new_inode->i_sb); 9383 9382 if (unlikely(btrfs_ino(new_inode) == 9384 9383 BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { 9385 9384 root_objectid = BTRFS_I(new_inode)->location.objectid; ··· 9857 9856 *alloc_hint = ins.objectid + ins.offset; 9858 9857 9859 9858 inode_inc_iversion(inode); 9860 - inode->i_ctime = CURRENT_TIME; 9859 + inode->i_ctime = current_fs_time(inode->i_sb); 9861 9860 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; 9862 9861 if (!(mode & FALLOC_FL_KEEP_SIZE) && 9863 9862 (actual_len > inode->i_size) &&
+4 -4
fs/btrfs/ioctl.c
··· 347 347 348 348 btrfs_update_iflags(inode); 349 349 inode_inc_iversion(inode); 350 - inode->i_ctime = CURRENT_TIME; 350 + inode->i_ctime = current_fs_time(inode->i_sb); 351 351 ret = btrfs_update_inode(trans, root, inode); 352 352 353 353 btrfs_end_transaction(trans, root); ··· 443 443 struct btrfs_root *root = BTRFS_I(dir)->root; 444 444 struct btrfs_root *new_root; 445 445 struct btrfs_block_rsv block_rsv; 446 - struct timespec cur_time = CURRENT_TIME; 446 + struct timespec cur_time = current_fs_time(dir->i_sb); 447 447 struct inode *inode; 448 448 int ret; 449 449 int err; ··· 3144 3144 3145 3145 inode_inc_iversion(inode); 3146 3146 if (!no_time_update) 3147 - inode->i_mtime = inode->i_ctime = CURRENT_TIME; 3147 + inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); 3148 3148 /* 3149 3149 * We round up to the block size at eof when determining which 3150 3150 * extents to clone above, but shouldn't round up the file size. ··· 4952 4952 struct btrfs_root *root = BTRFS_I(inode)->root; 4953 4953 struct btrfs_root_item *root_item = &root->root_item; 4954 4954 struct btrfs_trans_handle *trans; 4955 - struct timespec ct = CURRENT_TIME; 4955 + struct timespec ct = current_fs_time(inode->i_sb); 4956 4956 int ret = 0; 4957 4957 int received_uuid_changed; 4958 4958
+1 -1
fs/btrfs/root-tree.c
··· 488 488 struct btrfs_root *root) 489 489 { 490 490 struct btrfs_root_item *item = &root->root_item; 491 - struct timespec ct = CURRENT_TIME; 491 + struct timespec ct = current_fs_time(root->fs_info->sb); 492 492 493 493 spin_lock(&root->root_item_lock); 494 494 btrfs_set_root_ctransid(item, trans->transid);
+5 -2
fs/btrfs/transaction.c
··· 1333 1333 struct dentry *dentry; 1334 1334 struct extent_buffer *tmp; 1335 1335 struct extent_buffer *old; 1336 - struct timespec cur_time = CURRENT_TIME; 1336 + struct timespec cur_time; 1337 1337 int ret = 0; 1338 1338 u64 to_reserve = 0; 1339 1339 u64 index = 0; ··· 1380 1380 parent_inode = pending->dir; 1381 1381 parent_root = BTRFS_I(parent_inode)->root; 1382 1382 record_root_in_trans(trans, parent_root); 1383 + 1384 + cur_time = current_fs_time(parent_inode->i_sb); 1383 1385 1384 1386 /* 1385 1387 * insert the directory item ··· 1525 1523 1526 1524 btrfs_i_size_write(parent_inode, parent_inode->i_size + 1527 1525 dentry->d_name.len * 2); 1528 - parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME; 1526 + parent_inode->i_mtime = parent_inode->i_ctime = 1527 + current_fs_time(parent_inode->i_sb); 1529 1528 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode); 1530 1529 if (ret) { 1531 1530 btrfs_abort_transaction(trans, root, ret);
+1 -1
fs/btrfs/xattr.c
··· 249 249 goto out; 250 250 251 251 inode_inc_iversion(inode); 252 - inode->i_ctime = CURRENT_TIME; 252 + inode->i_ctime = current_fs_time(inode->i_sb); 253 253 set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags); 254 254 ret = btrfs_update_inode(trans, root, inode); 255 255 BUG_ON(ret);