diff mbox series

[v4,02/10] ext4: don't explicit update times in ext4_fallocate()

Message ID 20241216013915.3392419-3-yi.zhang@huaweicloud.com (mailing list archive)
State New
Headers show
Series ext4: clean up and refactor fallocate | expand

Commit Message

Zhang Yi Dec. 16, 2024, 1:39 a.m. UTC
From: Zhang Yi <yi.zhang@huawei.com>

After commit 'ad5cd4f4ee4d ("ext4: fix fallocate to use file_modified to
update permissions consistently"), we can update mtime and ctime
appropriately through file_modified() when doing zero range, collapse
rage, insert range and punch hole, hence there is no need to explicit
update times in those paths, just drop them.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/extents.c | 5 -----
 fs/ext4/inode.c   | 1 -
 2 files changed, 6 deletions(-)

Comments

Ojaswin Mujoo Dec. 18, 2024, 9:58 a.m. UTC | #1
On Mon, Dec 16, 2024 at 09:39:07AM +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> After commit 'ad5cd4f4ee4d ("ext4: fix fallocate to use file_modified to
> update permissions consistently"), we can update mtime and ctime
> appropriately through file_modified() when doing zero range, collapse
> rage, insert range and punch hole, hence there is no need to explicit
> update times in those paths, just drop them.
> 
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>

Looks good, feel free to add:

Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>

> ---
>  fs/ext4/extents.c | 5 -----
>  fs/ext4/inode.c   | 1 -
>  2 files changed, 6 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 8dc6b4271b15..7fb38aab241d 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4674,8 +4674,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
>  			goto out_mutex;
>  		}
>  
> -		inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
> -
>  		ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
>  					     flags);
>  		filemap_invalidate_unlock(mapping);
> @@ -4699,7 +4697,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
>  		goto out_mutex;
>  	}
>  
> -	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
>  	if (new_size)
>  		ext4_update_inode_size(inode, new_size);
>  	ret = ext4_mark_inode_dirty(handle, inode);
> @@ -5435,7 +5432,6 @@ static int ext4_collapse_range(struct file *file, loff_t offset, loff_t len)
>  	up_write(&EXT4_I(inode)->i_data_sem);
>  	if (IS_SYNC(inode))
>  		ext4_handle_sync(handle);
> -	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
>  	ret = ext4_mark_inode_dirty(handle, inode);
>  	ext4_update_inode_fsync_trans(handle, inode, 1);
>  
> @@ -5545,7 +5541,6 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len)
>  	/* Expand file to avoid data loss if there is error while shifting */
>  	inode->i_size += len;
>  	EXT4_I(inode)->i_disksize += len;
> -	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
>  	ret = ext4_mark_inode_dirty(handle, inode);
>  	if (ret)
>  		goto out_stop;
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index c68a8b841148..bf735d06b621 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4138,7 +4138,6 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
>  	if (IS_SYNC(inode))
>  		ext4_handle_sync(handle);
>  
> -	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
>  	ret2 = ext4_mark_inode_dirty(handle, inode);
>  	if (unlikely(ret2))
>  		ret = ret2;
> -- 
> 2.46.1
>
diff mbox series

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 8dc6b4271b15..7fb38aab241d 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4674,8 +4674,6 @@  static long ext4_zero_range(struct file *file, loff_t offset,
 			goto out_mutex;
 		}
 
-		inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
-
 		ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 					     flags);
 		filemap_invalidate_unlock(mapping);
@@ -4699,7 +4697,6 @@  static long ext4_zero_range(struct file *file, loff_t offset,
 		goto out_mutex;
 	}
 
-	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	if (new_size)
 		ext4_update_inode_size(inode, new_size);
 	ret = ext4_mark_inode_dirty(handle, inode);
@@ -5435,7 +5432,6 @@  static int ext4_collapse_range(struct file *file, loff_t offset, loff_t len)
 	up_write(&EXT4_I(inode)->i_data_sem);
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
-	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret = ext4_mark_inode_dirty(handle, inode);
 	ext4_update_inode_fsync_trans(handle, inode, 1);
 
@@ -5545,7 +5541,6 @@  static int ext4_insert_range(struct file *file, loff_t offset, loff_t len)
 	/* Expand file to avoid data loss if there is error while shifting */
 	inode->i_size += len;
 	EXT4_I(inode)->i_disksize += len;
-	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret = ext4_mark_inode_dirty(handle, inode);
 	if (ret)
 		goto out_stop;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c68a8b841148..bf735d06b621 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4138,7 +4138,6 @@  int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
 
-	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(ret2))
 		ret = ret2;