diff options
author | Sheng Yong <shengyong1@huawei.com> | 2017-06-25 22:41:36 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-07-07 13:34:45 -0400 |
commit | b855bf0e1640aa4cf2d1eef056eebcd43e0d1f5e (patch) | |
tree | bf67fc37e44ae3efb0f20b56f230b257519f9a38 | |
parent | d58dfb75056c5f732a0b83c54d22c99b4edc947a (diff) |
f2fs: do not set LOST_PINO for renamed dir
After renaming a directory, fsck could detect unmatched pino. The scenario
can be reproduced as the following:
$ mkdir /bar/subbar /foo
$ rename /bar/subbar /foo
Then fsck will report:
[ASSERT] (__chk_dots_dentries:1182) --> Bad inode number[0x3] for '..', parent parent ino is [0x4]
Rename sets LOST_PINO for old_inode. However, the flag cannot be cleared,
since dir is written back with CP. So, let's get rid of LOST_PINO for a
renamed dir and fix the pino directly at the end of rename.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/namei.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index c31b40e5f9cf..b75dc2f4ad57 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -772,7 +772,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
772 | } | 772 | } |
773 | 773 | ||
774 | down_write(&F2FS_I(old_inode)->i_sem); | 774 | down_write(&F2FS_I(old_inode)->i_sem); |
775 | file_lost_pino(old_inode); | 775 | if (!old_dir_entry || whiteout) |
776 | file_lost_pino(old_inode); | ||
777 | else | ||
778 | F2FS_I(old_inode)->i_pino = new_dir->i_ino; | ||
776 | up_write(&F2FS_I(old_inode)->i_sem); | 779 | up_write(&F2FS_I(old_inode)->i_sem); |
777 | 780 | ||
778 | old_inode->i_ctime = current_time(old_inode); | 781 | old_inode->i_ctime = current_time(old_inode); |