f2fs: avoid to set wrong pino of inode when rename dir
authorChao Yu <chao2.yu@samsung.com>
Sat, 21 Dec 2013 10:03:28 +0000 (18:03 +0800)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Mon, 23 Dec 2013 01:42:51 +0000 (10:42 +0900)
When we rename a dir to new name which is not exist previous,
we will set pino of parent inode with ino of child inode in f2fs_set_link.
It destroy consistency of pino, it should be fixed.

Thanks for previous work of Shu Tan.

Signed-off-by: Shu Tan <shu.tan@samsung.com>
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/dir.c
fs/f2fs/namei.c

index 28206109a29398df84b01f6ed0b1b54911c43f88..07ad850bbf97f5f975382f6d8ac6bc5100e3ae0b 100644 (file)
@@ -259,9 +259,6 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
        dir->i_mtime = dir->i_ctime = CURRENT_TIME;
        mark_inode_dirty(dir);
 
-       /* update parent inode number before releasing dentry page */
-       F2FS_I(inode)->i_pino = dir->i_ino;
-
        f2fs_put_page(page, 1);
 }
 
index 575adac17f8be2b55935498b0a49a15b78daddcf..a68838dae3356ce4bfb627d9dd636b4d1faedf96 100644 (file)
@@ -424,6 +424,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                }
 
                f2fs_set_link(new_dir, new_entry, new_page, old_inode);
+               F2FS_I(old_inode)->i_pino = new_dir->i_ino;
 
                new_inode->i_ctime = CURRENT_TIME;
                if (old_dir_entry)
@@ -457,6 +458,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                if (old_dir != new_dir) {
                        f2fs_set_link(old_inode, old_dir_entry,
                                                old_dir_page, new_dir);
+                       F2FS_I(old_inode)->i_pino = new_dir->i_ino;
                } else {
                        kunmap(old_dir_page);
                        f2fs_put_page(old_dir_page, 0);