Note, rename with old_inode (enc_name) and new_inode (no_enc_name), the result will be old_indoe(enc_name) and new_inode(enc_name).
Needs swap the enc_name flags? If needed, this patch needs update of clear the flags. otherwise, this patch only fix the logic with any result changing. Signed-off-by: Kinglong Mee <kinglong...@gmail.com> --- fs/f2fs/namei.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 3231a0a..db2ab7f 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -846,6 +846,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, struct page *old_page, *new_page; struct f2fs_dir_entry *old_dir_entry = NULL, *new_dir_entry = NULL; struct f2fs_dir_entry *old_entry, *new_entry; + bool old_inode_enc = false, new_inode_enc = false; int old_nlink = 0, new_nlink = 0; int err = -ENOENT; @@ -917,17 +918,16 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, f2fs_lock_op(sbi); + old_inode_enc = file_enc_name(old_inode); + new_inode_enc = file_enc_name(new_inode); + err = update_dent_inode(old_inode, new_inode, &new_dentry->d_name); if (err) goto out_unlock; - if (file_enc_name(new_inode)) - file_set_enc_name(old_inode); err = update_dent_inode(new_inode, old_inode, &old_dentry->d_name); if (err) goto out_undo; - if (file_enc_name(old_inode)) - file_set_enc_name(new_inode); /* update ".." directory entry info of old dentry */ if (old_dir_entry) @@ -942,6 +942,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, down_write(&F2FS_I(old_inode)->i_sem); file_lost_pino(old_inode); + if (new_inode_enc) + file_set_enc_name(old_inode); up_write(&F2FS_I(old_inode)->i_sem); old_dir->i_ctime = current_time(old_dir); @@ -957,6 +959,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, down_write(&F2FS_I(new_inode)->i_sem); file_lost_pino(new_inode); + if (old_inode_enc) + file_set_enc_name(new_inode); up_write(&F2FS_I(new_inode)->i_sem); new_dir->i_ctime = current_time(new_dir); -- 2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel