bfs: update target dirent when overwriting rename
PATCH 1/1 bfs: update target dirent when overwriting rename
When bfs_rename() overwrites an existing target, it drops the link count of the target inode but does not update the target directory entry to point to the source inode.
The in-memory dentry state looks correct until the filesystem is remounted. After remount, the target name still points to the old inode number, which has already been dropped.
Update the existing target directory entry with the source inode number and mark its metadata buffer dirty. Also update the target directory timestamp when the rename crosses directories.
Signed-off-by Yichong Chen <[email protected]>
--- fs/bfs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/bfs/dir.c +8 -0
@@ -238,6 +238,14 @@ static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, old_inode->i_ino);if (error) goto end_rename; + }else { + new_de->ino =cpu_to_le16 ((u16 )old_inode->i_ino); +mmb_mark_buffer_dirty (new_bh, &BFS_I (new_dir)->i_metadata_bhs); +if (new_dir != old_dir) { +inode_set_mtime_to_ts (new_dir, +inode_set_ctime_current (new_dir)); +mark_inode_dirty (new_dir); + } } old_de->ino =0 ;inode_set_mtime_to_ts (old_dir,inode_set_ctime_current (old_dir));
Signature · 1 line
2.51.0