Skip to contentSkip to conversation

f2fs: do not set LOST_PINO for created/renamed dir

RFC PATCH Superseded Sheng Yong 2 participants 2 messages Jun 22, 2017 – Jun 24, 2017 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sheng Yong

author
#0 lore raw

RFC PATCH 1/1 f2fs: do not set LOST_PINO for created/renamed dir

Since directories will be written back with checkpoint and fsync a directory will always write CP, there is no need to set LOST_PINO after creating or renaming a directory. During rename, fix dir's p_ino directly. Otherwise, fsck will find out that the pino does not match. 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]

---
 fs/f2fs/dir.c   | 3 ++-
 fs/f2fs/namei.c | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/f2fs/dir.c +2 -1
index 94756f55a97e..37f9c7f55605 100644
@@ -415,7 +415,8 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
 	 * We lost i_pino from now on.
 	 */
 	if (is_inode_flag_set(inode, FI_INC_LINK)) {
-		file_lost_pino(inode);
+		if (!S_ISDIR(inode->i_mode))
+			file_lost_pino(inode);
 		/*
 		 * If link the tmpfile to alias through linkat path,
 		 * we should remove this inode from orphan list.
fs/f2fs/namei.c +4 -1
index c31b40e5f9cf..b75dc2f4ad57 100644
@@ -772,7 +772,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	}
 
 	down_write(&F2FS_I(old_inode)->i_sem);
-	file_lost_pino(old_inode);
+	if (!old_dir_entry || whiteout)
+		file_lost_pino(old_inode);
+	else
+		F2FS_I(old_inode)->i_pino = new_dir->i_ino;
 	up_write(&F2FS_I(old_inode)->i_sem);
 
 	old_inode->i_ctime = current_time(old_inode);
Signature · 6 lines
2.13.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
maintainer
#1 lore raw

Hi Sheng Yong,

Quoted 2 lines · Sheng Yong

Since directories will be written back with checkpoint and fsync a directory will always write CP, there is no need to set LOST_PINO

Could you make another patch to fix unneeded flag setting in directory?

Thanks,

Quoted 36 lines

after creating or renaming a directory. During rename, fix dir's p_ino directly. Otherwise, fsck will find out that the pino does not match. 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]>

---
 fs/f2fs/dir.c   | 3 ++-
 fs/f2fs/namei.c | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/f2fs/dir.c +2 -1
index 94756f55a97e..37f9c7f55605 100644
@@ -415,7 +415,8 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
 	 * We lost i_pino from now on.
 	 */
 	if (is_inode_flag_set(inode, FI_INC_LINK)) {
-		file_lost_pino(inode);
+		if (!S_ISDIR(inode->i_mode))
+			file_lost_pino(inode);
 		/*
 		 * If link the tmpfile to alias through linkat path,
 		 * we should remove this inode from orphan list.
fs/f2fs/namei.c +0 -0
index c31b40e5f9cf..b75dc2f4ad57 100644
@@ -772,7 +772,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	}

fs/f2fs/namei.c static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, · line 781

Quoted 10 lines
fs/f2fs/namei.c +4 -1
 
 	down_write(&F2FS_I(old_inode)->i_sem);
-	file_lost_pino(old_inode);
+	if (!old_dir_entry || whiteout)
+		file_lost_pino(old_inode);
+	else
+		F2FS_I(old_inode)->i_pino = new_dir->i_ino;
 	up_write(&F2FS_I(old_inode)->i_sem);
 
 	old_inode->i_ctime = current_time(old_inode);

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot