Skip to contentSkip to conversation

exfat: preserve creation times during rename

PATCH Applied Hungyu Lin 3 participants 3 messages Oct 27

Subsystems (2)
lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH 1/1 exfat: preserve creation times during rename

exfat_rename() resets the destination parent directory's i_crtime after every successful rename. A normal mv within that directory therefore changes its STATX_BTIME, and the new creation time is also written to disk. Moving a child does not recreate its parent directory.

The function also resets i_crtime on an overwritten target inode. An application holding an open file descriptor can observe its birth time change even though it still refers to the same inode.

Remove both creation-time updates. simple_rename_timestamp() already updates the modification and change times required by rename, while creation times should remain unchanged. Jeff Layton questioned these updates during the timestamp accessor conversion, but they remain in the current implementation.

Fixes 5f2aa075070c ("exfat: add inode operations")
---
 fs/exfat/namei.c | 2 --
 1 file changed, 2 deletions(-)
fs/exfat/namei.c +0 -2
index 68ddb9c5504f..d01280570f70 100644
@@ -1293,7 +1293,6 @@ static int exfat_rename(const struct mnt_idmap *idmap,
 
 	inode_inc_iversion(new_dir);
 	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
-	EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
 	exfat_truncate_inode_atime(new_dir);
 	if (IS_DIRSYNC(new_dir) && size != i_size_read(new_dir))
 		exfat_sync_inode(new_dir);
@@ -1331,7 +1330,6 @@ static int exfat_rename(const struct mnt_idmap *idmap,
 			exfat_warn(sb, "abnormal access to an inode dropped");
 			WARN_ON(new_inode->i_nlink == 0);
 		}
-		EXFAT_I(new_inode)->i_crtime = current_time(new_inode);
 	}
 
 unlock:
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Hungyu Lin

exfat_rename() resets the destination parent directory's i_crtime after every successful rename. A normal mv within that directory therefore changes its STATX_BTIME, and the new creation time is also written to disk. Moving a child does not recreate its parent directory.

The function also resets i_crtime on an overwritten target inode. An application holding an open file descriptor can observe its birth time change even though it still refers to the same inode.

Remove both creation-time updates. simple_rename_timestamp() already updates the modification and change times required by rename, while creation times should remain unchanged. Jeff Layton questioned these updates during the timestamp accessor conversion, but they remain in the current implementation.

Fixes 5f2aa075070c ("exfat: add inode operations")
---
 fs/exfat/namei.c | 2 --
 1 file changed, 2 deletions(-)
fs/exfat/namei.c +0 -1
index 68ddb9c5504f..d01280570f70 100644
@@ -1293,7 +1293,6 @@ static int exfat_rename(const struct mnt_idmap *idmap,
 
 	inode_inc_iversion(new_dir);
 	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
-	EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
 	exfat_truncate_inode_atime(new_dir);
 	if (IS_DIRSYNC(new_dir) && size != i_size_read(new_dir))
 		exfat_sync_inode(new_dir);

fs/exfat/namei.c static int exfat_rename(const struct mnt_idmap *idmap, · line 1335

Quoted 7 lines
fs/exfat/namei.c +0 -1
@@ -1331,7 +1330,6 @@ static int exfat_rename(const struct mnt_idmap *idmap,
 			exfat_warn(sb, "abnormal access to an inode dropped");
 			WARN_ON(new_inode->i_nlink == 0);
 		}
-		EXFAT_I(new_inode)->i_crtime = current_time(new_inode);
 	}
 
 unlock:

To be clear, i_crtime is equivalent to the btime, so it shouldn't change on a rename.

maintainer Applied
#2 lore raw
In reply to Hungyu Lin
Quoted 16 lines · Hungyu Lin

exfat_rename() resets the destination parent directory's i_crtime after every successful rename. A normal mv within that directory therefore changes its STATX_BTIME, and the new creation time is also written to disk. Moving a child does not recreate its parent directory.

The function also resets i_crtime on an overwritten target inode. An application holding an open file descriptor can observe its birth time change even though it still refers to the same inode.

Remove both creation-time updates. simple_rename_timestamp() already updates the modification and change times required by rename, while creation times should remain unchanged. Jeff Layton questioned these updates during the timestamp accessor conversion, but they remain in the current implementation.

Quoted 4 lines
Fixes 5f2aa075070c ("exfat: add inode operations")

Applied it to #dev.
Thanks!