Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d5d30b2 authored by Sheng Yong's avatar Sheng Yong Committed by Jaegeuk Kim
Browse files

f2fs: do not set LOST_PINO for renamed dir



commit b855bf0e1640aa4cf2d1eef056eebcd43e0d1f5e upstream.

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: default avatarSheng Yong <shengyong1@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 437f4937
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -784,7 +784,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
	}
	}


	down_write(&F2FS_I(old_inode)->i_sem);
	down_write(&F2FS_I(old_inode)->i_sem);
	if (!old_dir_entry || whiteout)
		file_lost_pino(old_inode);
		file_lost_pino(old_inode);
	else
		F2FS_I(old_inode)->i_pino = new_dir->i_ino;
	up_write(&F2FS_I(old_inode)->i_sem);
	up_write(&F2FS_I(old_inode)->i_sem);


	old_inode->i_ctime = current_time(old_inode);
	old_inode->i_ctime = current_time(old_inode);