All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node
@ 2017-03-04 13:44 Kinglong Mee
  2017-03-05 12:33 ` Kinglong Mee
  2017-03-06 11:06 ` [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node Chao Yu
  0 siblings, 2 replies; 20+ messages in thread
From: Kinglong Mee @ 2017-03-04 13:44 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

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 <kinglongmee@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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-03-17 10:25 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-04 13:44 [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node Kinglong Mee
2017-03-05 12:33 ` Kinglong Mee
2017-03-06  6:57   ` [PATCH] f2fs: sync the enc name flags with disk level filename Kinglong Mee
2017-03-06  8:11     ` [PATCH v2] " Kinglong Mee
2017-03-07 19:30       ` Jaegeuk Kim
2017-03-08 10:56         ` Kinglong Mee
2017-03-10  2:00           ` Kinglong Mee
2017-03-10  2:23             ` Jaegeuk Kim
2017-03-10  8:28               ` [PATCH v3] f2fs: cleanup the disk level filename updating Kinglong Mee
2017-03-13 18:23                 ` Jaegeuk Kim
2017-03-13 23:14                   ` Kinglong Mee
2017-03-14 19:53                     ` Jaegeuk Kim
2017-03-17  7:04                 ` Chao Yu
2017-03-17  7:30                   ` Kinglong Mee
2017-03-17 10:24                     ` Chao Yu
2017-03-08 12:14       ` [PATCH v2] f2fs: sync the enc name flags with disk level filename Chao Yu
2017-03-08 13:16         ` Kinglong Mee
2017-03-09  1:30           ` Chao Yu
2017-03-06 11:06 ` [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node Chao Yu
2017-03-06 11:10   ` Kinglong Mee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.