mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									8f682f6955
								
							
						
					
					
						commit
						04b285f35e
					
				
					 6 changed files with 26 additions and 22 deletions
				
			
		| 
						 | 
					@ -2544,7 +2544,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 | 
				
			||||||
		goto out_free;
 | 
							goto out_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inode_inc_iversion(inode);
 | 
						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;
 | 
						trans->block_rsv = &root->fs_info->trans_block_rsv;
 | 
				
			||||||
	ret = btrfs_update_inode(trans, root, inode);
 | 
						ret = btrfs_update_inode(trans, root, inode);
 | 
				
			||||||
| 
						 | 
					@ -2794,7 +2794,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 | 
				
			||||||
		if (IS_ERR(trans)) {
 | 
							if (IS_ERR(trans)) {
 | 
				
			||||||
			ret = PTR_ERR(trans);
 | 
								ret = PTR_ERR(trans);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			inode->i_ctime = CURRENT_TIME;
 | 
								inode->i_ctime = current_fs_time(inode->i_sb);
 | 
				
			||||||
			i_size_write(inode, actual_end);
 | 
								i_size_write(inode, actual_end);
 | 
				
			||||||
			btrfs_ordered_update_i_size(inode, actual_end, NULL);
 | 
								btrfs_ordered_update_i_size(inode, actual_end, NULL);
 | 
				
			||||||
			ret = btrfs_update_inode(trans, root, inode);
 | 
								ret = btrfs_update_inode(trans, root, inode);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4013,7 +4013,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	btrfs_i_size_write(dir, dir->i_size - name_len * 2);
 | 
						btrfs_i_size_write(dir, dir->i_size - name_len * 2);
 | 
				
			||||||
	inode_inc_iversion(inode);
 | 
						inode_inc_iversion(inode);
 | 
				
			||||||
	inode_inc_iversion(dir);
 | 
						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);
 | 
						ret = btrfs_update_inode(trans, root, dir);
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	return ret;
 | 
						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);
 | 
						btrfs_i_size_write(dir, dir->i_size - name_len * 2);
 | 
				
			||||||
	inode_inc_iversion(dir);
 | 
						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);
 | 
						ret = btrfs_update_inode_fallback(trans, root, dir);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		btrfs_abort_transaction(trans, root, 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_op = &btrfs_dir_ro_inode_operations;
 | 
				
			||||||
	inode->i_fop = &simple_dir_operations;
 | 
						inode->i_fop = &simple_dir_operations;
 | 
				
			||||||
	inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
 | 
						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_atime = inode->i_mtime;
 | 
				
			||||||
	inode->i_ctime = inode->i_mtime;
 | 
						inode->i_ctime = inode->i_mtime;
 | 
				
			||||||
	BTRFS_I(inode)->i_otime = 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_init_owner(inode, dir, mode);
 | 
				
			||||||
	inode_set_bytes(inode, 0);
 | 
						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_atime = inode->i_mtime;
 | 
				
			||||||
	inode->i_ctime = inode->i_mtime;
 | 
						inode->i_ctime = inode->i_mtime;
 | 
				
			||||||
	BTRFS_I(inode)->i_otime = 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 +
 | 
						btrfs_i_size_write(parent_inode, parent_inode->i_size +
 | 
				
			||||||
			   name_len * 2);
 | 
								   name_len * 2);
 | 
				
			||||||
	inode_inc_iversion(parent_inode);
 | 
						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);
 | 
						ret = btrfs_update_inode(trans, root, parent_inode);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		btrfs_abort_transaction(trans, root, 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;
 | 
						BTRFS_I(inode)->dir_index = 0ULL;
 | 
				
			||||||
	inc_nlink(inode);
 | 
						inc_nlink(inode);
 | 
				
			||||||
	inode_inc_iversion(inode);
 | 
						inode_inc_iversion(inode);
 | 
				
			||||||
	inode->i_ctime = CURRENT_TIME;
 | 
						inode->i_ctime = current_fs_time(inode->i_sb);
 | 
				
			||||||
	ihold(inode);
 | 
						ihold(inode);
 | 
				
			||||||
	set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
 | 
						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 btrfs_root *dest = BTRFS_I(new_dir)->root;
 | 
				
			||||||
	struct inode *new_inode = d_inode(new_dentry);
 | 
						struct inode *new_inode = d_inode(new_dentry);
 | 
				
			||||||
	struct inode *old_inode = d_inode(old_dentry);
 | 
						struct inode *old_inode = d_inode(old_dentry);
 | 
				
			||||||
	struct timespec ctime = CURRENT_TIME;
 | 
					 | 
				
			||||||
	u64 index = 0;
 | 
						u64 index = 0;
 | 
				
			||||||
	u64 root_objectid;
 | 
						u64 root_objectid;
 | 
				
			||||||
	int ret;
 | 
						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(old_dir);
 | 
				
			||||||
	inode_inc_iversion(new_dir);
 | 
						inode_inc_iversion(new_dir);
 | 
				
			||||||
	inode_inc_iversion(old_inode);
 | 
						inode_inc_iversion(old_inode);
 | 
				
			||||||
	old_dir->i_ctime = old_dir->i_mtime = ctime;
 | 
						old_dir->i_ctime = old_dir->i_mtime =
 | 
				
			||||||
	new_dir->i_ctime = new_dir->i_mtime = ctime;
 | 
						new_dir->i_ctime = new_dir->i_mtime =
 | 
				
			||||||
	old_inode->i_ctime = ctime;
 | 
						old_inode->i_ctime = current_fs_time(old_dir->i_sb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (old_dentry->d_parent != new_dentry->d_parent)
 | 
						if (old_dentry->d_parent != new_dentry->d_parent)
 | 
				
			||||||
		btrfs_record_unlink_dir(trans, old_dir, old_inode, 1);
 | 
							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) {
 | 
						if (new_inode) {
 | 
				
			||||||
		inode_inc_iversion(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) ==
 | 
							if (unlikely(btrfs_ino(new_inode) ==
 | 
				
			||||||
			     BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
 | 
								     BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
 | 
				
			||||||
			root_objectid = BTRFS_I(new_inode)->location.objectid;
 | 
								root_objectid = BTRFS_I(new_inode)->location.objectid;
 | 
				
			||||||
| 
						 | 
					@ -9856,7 +9857,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
 | 
				
			||||||
		*alloc_hint = ins.objectid + ins.offset;
 | 
							*alloc_hint = ins.objectid + ins.offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inode_inc_iversion(inode);
 | 
							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;
 | 
							BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
 | 
				
			||||||
		if (!(mode & FALLOC_FL_KEEP_SIZE) &&
 | 
							if (!(mode & FALLOC_FL_KEEP_SIZE) &&
 | 
				
			||||||
		    (actual_len > inode->i_size) &&
 | 
							    (actual_len > inode->i_size) &&
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -347,7 +347,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	btrfs_update_iflags(inode);
 | 
						btrfs_update_iflags(inode);
 | 
				
			||||||
	inode_inc_iversion(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);
 | 
						ret = btrfs_update_inode(trans, root, inode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	btrfs_end_transaction(trans, root);
 | 
						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 *root = BTRFS_I(dir)->root;
 | 
				
			||||||
	struct btrfs_root *new_root;
 | 
						struct btrfs_root *new_root;
 | 
				
			||||||
	struct btrfs_block_rsv block_rsv;
 | 
						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;
 | 
						struct inode *inode;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
| 
						 | 
					@ -3144,7 +3144,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inode_inc_iversion(inode);
 | 
						inode_inc_iversion(inode);
 | 
				
			||||||
	if (!no_time_update)
 | 
						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
 | 
						 * We round up to the block size at eof when determining which
 | 
				
			||||||
	 * extents to clone above, but shouldn't round up the file size.
 | 
						 * 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 *root = BTRFS_I(inode)->root;
 | 
				
			||||||
	struct btrfs_root_item *root_item = &root->root_item;
 | 
						struct btrfs_root_item *root_item = &root->root_item;
 | 
				
			||||||
	struct btrfs_trans_handle *trans;
 | 
						struct btrfs_trans_handle *trans;
 | 
				
			||||||
	struct timespec ct = CURRENT_TIME;
 | 
						struct timespec ct = current_fs_time(inode->i_sb);
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
	int received_uuid_changed;
 | 
						int received_uuid_changed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -488,7 +488,7 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans,
 | 
				
			||||||
			     struct btrfs_root *root)
 | 
								     struct btrfs_root *root)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct btrfs_root_item *item = &root->root_item;
 | 
						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);
 | 
						spin_lock(&root->root_item_lock);
 | 
				
			||||||
	btrfs_set_root_ctransid(item, trans->transid);
 | 
						btrfs_set_root_ctransid(item, trans->transid);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1333,7 +1333,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	struct dentry *dentry;
 | 
						struct dentry *dentry;
 | 
				
			||||||
	struct extent_buffer *tmp;
 | 
						struct extent_buffer *tmp;
 | 
				
			||||||
	struct extent_buffer *old;
 | 
						struct extent_buffer *old;
 | 
				
			||||||
	struct timespec cur_time = CURRENT_TIME;
 | 
						struct timespec cur_time;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
	u64 to_reserve = 0;
 | 
						u64 to_reserve = 0;
 | 
				
			||||||
	u64 index = 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;
 | 
						parent_root = BTRFS_I(parent_inode)->root;
 | 
				
			||||||
	record_root_in_trans(trans, parent_root);
 | 
						record_root_in_trans(trans, parent_root);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cur_time = current_fs_time(parent_inode->i_sb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * insert the directory item
 | 
						 * 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 +
 | 
						btrfs_i_size_write(parent_inode, parent_inode->i_size +
 | 
				
			||||||
					 dentry->d_name.len * 2);
 | 
										 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);
 | 
						ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode);
 | 
				
			||||||
	if (ret) {
 | 
						if (ret) {
 | 
				
			||||||
		btrfs_abort_transaction(trans, root, ret);
 | 
							btrfs_abort_transaction(trans, root, ret);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -249,7 +249,7 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans,
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inode_inc_iversion(inode);
 | 
						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);
 | 
						set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
 | 
				
			||||||
	ret = btrfs_update_inode(trans, root, inode);
 | 
						ret = btrfs_update_inode(trans, root, inode);
 | 
				
			||||||
	BUG_ON(ret);
 | 
						BUG_ON(ret);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue