Skip to contentSkip to conversation

f2fs: update mtime and ctime in move file range method

PATCH Superseded Yunlei He 2 participants 5 messages Jun 21, 2023 – Jun 22, 2023 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

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.

---
v2:
-update both src and dst inode

 fs/f2fs/file.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
fs/f2fs/file.c +14 -0
index cb42d8464ad9..4adcf62e2665 100644
@@ -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);
Signature · 1 line
2.40.1
author
#1 lore raw

PATCH 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.

---
 fs/f2fs/file.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/file.c +3 -0
index 4adcf62e2665..25ef36f2376a 100644
@@ -2897,6 +2897,9 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 			f2fs_mark_inode_dirty_sync(dst, false);
 		}
 
+		truncate_pagecache_range(src, pos_in, pos_in + len - 1);
+		truncate_pagecache_range(dst, pos_out, pos_out + len - 1);
+
 		f2fs_update_time(F2FS_I_SB(src), REQ_TIME);
 	}
 
Signature · 1 line
2.40.1
maintainer
#3 lore raw
In reply to Yunlei He
Quoted 15 lines · Yunlei He

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

---
v2:

(quoted diff) +0 -1
-update both src and dst inode
  fs/f2fs/file.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
fs/f2fs/file.c +0 -0
index cb42d8464ad9..4adcf62e2665 100644

fs/f2fs/file.c static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · line 2887

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -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.

fs/f2fs/file.c static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · line 2900

Quoted 13 lines
fs/f2fs/file.c +11 -0
  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,

Quoted 5 lines
fs/f2fs/file.c +2 -0
+	}
+
  out_unlock:
  	if (src != dst)
  		inode_unlock(dst);
#4 lore raw
Quoted 23 lines · Chao Yu
Quoted 15 lines · Yunlei He

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

---
v2:
-update both src and dst inode
  fs/f2fs/file.c | 14 ++++++++++++++

  1 file changed, 14 insertions(+)
fs/f2fs/file.c +0 -0
index cb42d8464ad9..4adcf62e2665 100644

fs/f2fs/file.c static int f2fs_move_file_range(struct file · line 2887

Quoted 4 lines
fs/f2fs/file.c +1 -0
@@ -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.

Quoted 15 lines

fs/f2fs/file.c static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · line 2900

Quoted 13 lines

  out_src:
      f2fs_up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);

fs/f2fs/file.c +11 -0
+
+    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,

Quoted 8 lines

Thanks,

Quoted 5 lines

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