All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kinglong Mee <kinglongmee@gmail.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node
Date: Sat, 4 Mar 2017 21:44:04 +0800	[thread overview]
Message-ID: <fdfcad9e-36e6-a163-e42b-abe414c2ca9d@gmail.com> (raw)

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

             reply	other threads:[~2017-03-04 13:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 13:44 Kinglong Mee [this message]
2017-03-05 12:33 ` [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fdfcad9e-36e6-a163-e42b-abe414c2ca9d@gmail.com \
    --to=kinglongmee@gmail.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.