f2fs: update mtime and ctime in move file range method
PATCH v2 1/2 f2fs: update mtime and ctime in move file range method
Mtime and ctime stay old value without update after move file range ioctl. This patch add time update.
Signed-off-by Yunlei He <[email protected]>
---
v2:
-update both src and dst inode
fs/f2fs/file.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/f2fs/file.c +11 -0
@@ -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);
Signature · 1 line
2.40.1
PATCH v2 2/2 f2fs: truncate pages if move file range success
If move file range success, it should remove old data from src and dst page cache.
Signed-off-by Yunlei He <[email protected]>
---
v2:
-truncate pages with filemap invalidate lock
-should drop extent cache
fs/f2fs/file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/f2fs/file.c +16 -0
@@ -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) {
Signature · 1 line
2.40.1
Quoted 4 lines · Yunlei He
Mtime and ctime stay old value without update after move file range ioctl. This patch add time update.
Signed-off-by Yunlei He <[email protected]>
Reviewed-by Chao Yu <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel