linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
@ 2023-06-21  9:43 Yunlei He via Linux-f2fs-devel
  2023-06-21 13:39 ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: Yunlei He via Linux-f2fs-devel @ 2023-06-21  9:43 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

Mtime and ctime stay old value without update after move
file range ioctl. This patch add time update.

Signed-off-by: Yunlei He <heyunlei@oppo.com>
---
v2:
-update both src and dst inode
 fs/f2fs/file.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index cb42d8464ad9..4adcf62e2665 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2884,8 +2884,22 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 
 	if (src != dst)
 		f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
+
 out_src:
 	f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
+
+	if (!ret) {
+		src->i_mtime = src->i_ctime = current_time(src);
+		f2fs_mark_inode_dirty_sync(src, false);
+
+		if (src != dst) {
+			dst->i_mtime = dst->i_ctime = current_time(dst);
+			f2fs_mark_inode_dirty_sync(dst, false);
+		}
+
+		f2fs_update_time(F2FS_I_SB(src), REQ_TIME);
+	}
+
 out_unlock:
 	if (src != dst)
 		inode_unlock(dst);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
  2023-06-21  9:43 Yunlei He via Linux-f2fs-devel
@ 2023-06-21 13:39 ` Chao Yu
  2023-06-22 16:23   ` 何云蕾(Yunlei he) via Linux-f2fs-devel
  0 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2023-06-21 13:39 UTC (permalink / raw)
  To: Yunlei He, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2023/6/21 17:43, Yunlei He wrote:
> Mtime and ctime stay old value without update after move
> file range ioctl. This patch add time update.
> 
> Signed-off-by: Yunlei He <heyunlei@oppo.com>
> ---
> v2:
> -update both src and dst inode
>   fs/f2fs/file.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index cb42d8464ad9..4adcf62e2665 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2884,8 +2884,22 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
>   
>   	if (src != dst)
>   		f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
> +

Unneeded blank line.

>   out_src:
>   	f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
> +
> +	if (!ret) {
> +		src->i_mtime = src->i_ctime = current_time(src);
> +		f2fs_mark_inode_dirty_sync(src, false);
> +
> +		if (src != dst) {
> +			dst->i_mtime = dst->i_ctime = current_time(dst);
> +			f2fs_mark_inode_dirty_sync(dst, false);
> +		}
> +
> +		f2fs_update_time(F2FS_I_SB(src), REQ_TIME);

f2fs_update_time(sbi, REQ_TIME);

Thanks,

> +	}
> +
>   out_unlock:
>   	if (src != dst)
>   		inode_unlock(dst);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
@ 2023-06-22 16:16 Yunlei He via Linux-f2fs-devel
  2023-06-23  1:42 ` Chao Yu
  2023-06-23 18:55 ` Jaegeuk Kim
  0 siblings, 2 replies; 9+ messages in thread
From: Yunlei He via Linux-f2fs-devel @ 2023-06-22 16:16 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

Mtime and ctime stay old value without update after move
file range ioctl. This patch add time update.

Signed-off-by: Yunlei He <heyunlei@oppo.com>
---
v2:
-update both src and dst inode
 fs/f2fs/file.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index cb42d8464ad9..e59fc8faa035 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2886,6 +2886,19 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 		f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
 out_src:
 	f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
+
+	if (!ret) {
+		src->i_mtime = src->i_ctime = current_time(src);
+		f2fs_mark_inode_dirty_sync(src, false);
+
+		if (src != dst) {
+			dst->i_mtime = dst->i_ctime = current_time(dst);
+			f2fs_mark_inode_dirty_sync(dst, false);
+		}
+
+		f2fs_update_time(sbi, REQ_TIME);
+	}
+
 out_unlock:
 	if (src != dst)
 		inode_unlock(dst);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
  2023-06-21 13:39 ` Chao Yu
@ 2023-06-22 16:23   ` 何云蕾(Yunlei he) via Linux-f2fs-devel
  0 siblings, 0 replies; 9+ messages in thread
From: 何云蕾(Yunlei he) via Linux-f2fs-devel @ 2023-06-22 16:23 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel


On 2023/6/21 21:39, Chao Yu wrote:
> On 2023/6/21 17:43, Yunlei He wrote:
>> Mtime and ctime stay old value without update after move
>> file range ioctl. This patch add time update.
>>
>> Signed-off-by: Yunlei He <heyunlei@oppo.com>
>> ---
>> v2:
>> -update both src and dst inode
>>   fs/f2fs/file.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index cb42d8464ad9..4adcf62e2665 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -2884,8 +2884,22 @@ static int f2fs_move_file_range(struct file 
>> *file_in, loff_t pos_in,
>>         if (src != dst)
>>           f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
>> +
>
> Unneeded blank line.
>
>>   out_src:
>>       f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
>> +
>> +    if (!ret) {
>> +        src->i_mtime = src->i_ctime = current_time(src);
>> +        f2fs_mark_inode_dirty_sync(src, false);
>> +
>> +        if (src != dst) {
>> +            dst->i_mtime = dst->i_ctime = current_time(dst);
>> +            f2fs_mark_inode_dirty_sync(dst, false);
>> +        }
>> +
>> +        f2fs_update_time(F2FS_I_SB(src), REQ_TIME);
>
> f2fs_update_time(sbi, REQ_TIME);
Hi Chao,

     Thanks for your review, I have resend this patch set.

Thanks,

>
> Thanks,
>
>> +    }
>> +
>>   out_unlock:
>>       if (src != dst)
>>           inode_unlock(dst);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
  2023-06-22 16:16 Yunlei He via Linux-f2fs-devel
@ 2023-06-23  1:42 ` Chao Yu
  2023-06-23 18:55 ` Jaegeuk Kim
  1 sibling, 0 replies; 9+ messages in thread
From: Chao Yu @ 2023-06-23  1:42 UTC (permalink / raw)
  To: Yunlei He, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2023/6/23 0:16, Yunlei He wrote:
> Mtime and ctime stay old value without update after move
> file range ioctl. This patch add time update.
> 
> Signed-off-by: Yunlei He <heyunlei@oppo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
  2023-06-22 16:16 Yunlei He via Linux-f2fs-devel
  2023-06-23  1:42 ` Chao Yu
@ 2023-06-23 18:55 ` Jaegeuk Kim
  1 sibling, 0 replies; 9+ messages in thread
From: Jaegeuk Kim @ 2023-06-23 18:55 UTC (permalink / raw)
  To: Yunlei He; +Cc: linux-kernel, linux-f2fs-devel

On 06/23, Yunlei He wrote:
> Mtime and ctime stay old value without update after move
> file range ioctl. This patch add time update.
> 
> Signed-off-by: Yunlei He <heyunlei@oppo.com>
> ---
> v2:
> -update both src and dst inode
>  fs/f2fs/file.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index cb42d8464ad9..e59fc8faa035 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2886,6 +2886,19 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
>  		f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
>  out_src:
>  	f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
> +
> +	if (!ret) {

Applied with minor change like:

	if (ret)
		goto out_unlock;
	...

> +		src->i_mtime = src->i_ctime = current_time(src);
> +		f2fs_mark_inode_dirty_sync(src, false);
> +
> +		if (src != dst) {
> +			dst->i_mtime = dst->i_ctime = current_time(dst);
> +			f2fs_mark_inode_dirty_sync(dst, false);
> +		}
> +
> +		f2fs_update_time(sbi, REQ_TIME);
> +	}
> +
>  out_unlock:
>  	if (src != dst)
>  		inode_unlock(dst);
> -- 
> 2.40.1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
@ 2023-06-25 16:06 Yunlei He via Linux-f2fs-devel
  2023-06-25 16:06 ` [f2fs-dev] [PATCH 2/2 v2] f2fs: truncate pages if move file range success Yunlei He via Linux-f2fs-devel
  2023-06-26  9:15 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method Chao Yu
  0 siblings, 2 replies; 9+ messages in thread
From: Yunlei He via Linux-f2fs-devel @ 2023-06-25 16:06 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

Mtime and ctime stay old value without update after move
file range ioctl. This patch add time update.

Signed-off-by: Yunlei He <heyunlei@oppo.com>
---
v2:
-update both src and dst inode
 fs/f2fs/file.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index cb42d8464ad9..5af7e57b6140 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2886,6 +2886,17 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 		f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
 out_src:
 	f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
+	if (ret)
+		goto out_unlock;
+
+	src->i_mtime = src->i_ctime = current_time(src);
+	f2fs_mark_inode_dirty_sync(src, false);
+	if (src != dst) {
+		dst->i_mtime = dst->i_ctime = current_time(dst);
+		f2fs_mark_inode_dirty_sync(dst, false);
+	}
+
+	f2fs_update_time(sbi, REQ_TIME);
 out_unlock:
 	if (src != dst)
 		inode_unlock(dst);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [f2fs-dev] [PATCH 2/2 v2] f2fs: truncate pages if move file range success
  2023-06-25 16:06 [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method Yunlei He via Linux-f2fs-devel
@ 2023-06-25 16:06 ` Yunlei He via Linux-f2fs-devel
  2023-06-26  9:15 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method Chao Yu
  1 sibling, 0 replies; 9+ messages in thread
From: Yunlei He via Linux-f2fs-devel @ 2023-06-25 16:06 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

If move file range success, it should remove old data from
src and dst page cache.

Signed-off-by: Yunlei He <heyunlei@oppo.com>
---
v2:
-truncate pages with filemap invalidate lock
-should drop extent cache
 fs/f2fs/file.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 5af7e57b6140..7b3b333f96f5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2869,7 +2869,13 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 			goto out_src;
 	}
 
+	filemap_invalidate_lock_two(src->i_mapping, dst->i_mapping);
+	truncate_pagecache_range(src, pos_in, pos_in + len - 1);
+	truncate_pagecache_range(dst, pos_out, pos_out + len - 1);
+
 	f2fs_lock_op(sbi);
+	f2fs_drop_extent_tree(src);
+	f2fs_drop_extent_tree(dst);
 	ret = __exchange_data_block(src, dst, pos_in >> F2FS_BLKSIZE_BITS,
 				pos_out >> F2FS_BLKSIZE_BITS,
 				len >> F2FS_BLKSIZE_BITS, false);
@@ -2881,14 +2887,24 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 			f2fs_i_size_write(dst, dst_osize);
 	}
 	f2fs_unlock_op(sbi);
+	filemap_invalidate_unlock_two(src->i_mapping, dst->i_mapping);
 
 	if (src != dst)
 		f2fs_up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
 out_src:
 	f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
+
 	if (ret)
 		goto out_unlock;
 
+	/* write out all moved pages, if possible */
+	filemap_invalidate_lock_two(src->i_mapping, dst->i_mapping);
+	filemap_write_and_wait_range(dst->i_mapping,
+					pos_out, pos_out + len);
+	truncate_pagecache_range(dst, pos_out, pos_out + len - 1);
+	truncate_pagecache_range(src, pos_in, pos_in + len - 1);
+	filemap_invalidate_unlock_two(src->i_mapping, dst->i_mapping);
+
 	src->i_mtime = src->i_ctime = current_time(src);
 	f2fs_mark_inode_dirty_sync(src, false);
 	if (src != dst) {
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method
  2023-06-25 16:06 [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method Yunlei He via Linux-f2fs-devel
  2023-06-25 16:06 ` [f2fs-dev] [PATCH 2/2 v2] f2fs: truncate pages if move file range success Yunlei He via Linux-f2fs-devel
@ 2023-06-26  9:15 ` Chao Yu
  1 sibling, 0 replies; 9+ messages in thread
From: Chao Yu @ 2023-06-26  9:15 UTC (permalink / raw)
  To: Yunlei He, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2023/6/26 0:06, Yunlei He wrote:
> Mtime and ctime stay old value without update after move
> file range ioctl. This patch add time update.
> 
> Signed-off-by: Yunlei He <heyunlei@oppo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-26  9:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-25 16:06 [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method Yunlei He via Linux-f2fs-devel
2023-06-25 16:06 ` [f2fs-dev] [PATCH 2/2 v2] f2fs: truncate pages if move file range success Yunlei He via Linux-f2fs-devel
2023-06-26  9:15 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: update mtime and ctime in move file range method Chao Yu
  -- strict thread matches above, loose matches on Subject: below --
2023-06-22 16:16 Yunlei He via Linux-f2fs-devel
2023-06-23  1:42 ` Chao Yu
2023-06-23 18:55 ` Jaegeuk Kim
2023-06-21  9:43 Yunlei He via Linux-f2fs-devel
2023-06-21 13:39 ` Chao Yu
2023-06-22 16:23   ` 何云蕾(Yunlei he) via Linux-f2fs-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).