Skip to contentSkip to conversation

f2fs: avoid dead loop in function find_fsync_dnodes

PATCH Superseded Yunlei He 3 participants 6 messages Dec 20, 2017 – Jan 4, 2018 F2FS file system

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH v5 1/1 f2fs: avoid dead loop in function find_fsync_dnodes

v4 -> v5 return err instead destory inode list for two reasons:
i. avoid duplicated destroy inode list in function recover_fsync_data. ii. report an error for recovery, and set need_fsck flag

Came across a dead loop in recovery like this:

......

[   24.680480s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597696
[   24.698394s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597697
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724426s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698

......

Mount process will block in dead loop and fsck can do nothing with this error, This patch abandon recovery if node chain is cyclical.

---
 fs/f2fs/recovery.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/recovery.c +11 -0
index d025aa8..a535ec2 100644
@@ -216,6 +216,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 			return 0;
 
 		page = get_tmp_page(sbi, blkaddr);
+		if (PageChecked(page)) {
+			f2fs_msg(sbi->sb, KERN_ERR, "Abandon looped node block list");
+			err = -EINVAL;
+			break;
+		}
+
+		/*
+		 * it's not needed to clear PG_checked flag in temp page since we
+		 * will truncate all those pages in the end of recovery.
+		 */
+		SetPageChecked(page);
 
 		if (!is_recoverable_dnode(page))
 			break;
Signature · 6 lines
1.9.1


------------------------------------------------------------------------------
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 Yunlei,

Quoted 34 lines · Yunlei He

v4 -> v5 return err instead destory inode list for two reasons:
i. avoid duplicated destroy inode list in function recover_fsync_data. ii. report an error for recovery, and set need_fsck flag

Came across a dead loop in recovery like this:

......

[   24.680480s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597696
[   24.698394s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597697
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724426s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698

......

Mount process will block in dead loop and fsck can do nothing with this error, This patch abandon recovery if node chain is cyclical.

---
 fs/f2fs/recovery.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/recovery.c +0 -0
index d025aa8..a535ec2 100644

fs/f2fs/recovery.c static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) · line 221

Quoted 6 lines
fs/f2fs/recovery.c +3 -0
@@ -216,6 +216,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 			return 0;
 
 		page = get_tmp_page(sbi, blkaddr);
+		if (PageChecked(page)) {
+			f2fs_msg(sbi->sb, KERN_ERR, "Abandon looped node block list");
+			err = -EINVAL;

Is there any problem, if we break here without error, so that we could recover some of the inodes in the chain as best efforts?

Thanks,

Quoted 13 lines
fs/f2fs/recovery.c +8 -0
+			break;
+		}
+
+		/*
+		 * it's not needed to clear PG_checked flag in temp page since we
+		 * will truncate all those pages in the end of recovery.
+		 */
+		SetPageChecked(page);
 
 		if (!is_recoverable_dnode(page))
 			break;
Signature · 1 line
1.9.1

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

author
#2 lore raw
Quoted 10 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Thursday, December 21, 2017 5:01 AM
To: heyunlei
Cc: Yuchao (T); [email protected]; Wangbintian; Jianing (Euler)
Subject: Re: [f2fs-dev][PATCH v5] f2fs: avoid dead loop in function find_fsync_dnodes

Hi Yunlei,

Hi Kim,

Quoted 38 lines · Yunlei He
Quoted 36 lines

v4 -> v5 return err instead destory inode list for two reasons:
i. avoid duplicated destroy inode list in function recover_fsync_data. ii. report an error for recovery, and set need_fsck flag

Came across a dead loop in recovery like this:

......

[   24.680480s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597696
[   24.698394s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597697
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724426s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698

......

Mount process will block in dead loop and fsck can do nothing with this error, This patch abandon recovery if node chain is cyclical.

---
 fs/f2fs/recovery.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/recovery.c +0 -0
index d025aa8..a535ec2 100644
@@ -216,6 +216,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 			return 0;
 
Quoted 7 lines

fs/f2fs/recovery.c static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) · line 221

Quoted 4 lines
fs/f2fs/recovery.c +3 -0
 		page = get_tmp_page(sbi, blkaddr);
+		if (PageChecked(page)) {
+			f2fs_msg(sbi->sb, KERN_ERR, "Abandon looped node block list");
+			err = -EINVAL;

Is there any problem, if we break here without error, so that we could recover some of the inodes in the chain as best efforts?

I think it's a corner case caused by some weird reason. Maybe data in recover node Chain is also polluted and unreliable. So I think we'd better abandon this recovery.

Thanks,

Quoted 12 lines

Thanks,

Quoted 9 lines
fs/f2fs/recovery.c +8 -0
+			break;
+		}
+
+		/*
+		 * it's not needed to clear PG_checked flag in temp page since we
+		 * will truncate all those pages in the end of recovery.
+		 */
+		SetPageChecked(page);
 
Quoted 4 lines
Quoted 4 lines
fs/f2fs/recovery.c +0 -1
 		if (!is_recoverable_dnode(page))
 			break;
--

1.9.1

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
In reply to Yunlei He
Quoted 3 lines · Yunlei He

v4 -> v5 return err instead destory inode list for two reasons:
i. avoid duplicated destroy inode list in function recover_fsync_data. ii. report an error for recovery, and set need_fsck flag

fsck can't fix this issue so far, it doesn't work even we set need_fsck flag, would it be better to just drop last dnode with corrupted next_blkaddr and try our best to recover fsynced data?

Thanks,

Quoted 39 lines

Came across a dead loop in recovery like this:

......

[   24.680480s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597696
[   24.698394s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597697
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724426s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698

......

Mount process will block in dead loop and fsck can do nothing with this error, This patch abandon recovery if node chain is cyclical.

---
 fs/f2fs/recovery.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/recovery.c +4 -0
index d025aa8..a535ec2 100644
@@ -216,6 +216,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 			return 0;
 
 		page = get_tmp_page(sbi, blkaddr);
+		if (PageChecked(page)) {
+			f2fs_msg(sbi->sb, KERN_ERR, "Abandon looped node block list");
+			err = -EINVAL;
+			break;

fs/f2fs/recovery.c static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) · line 232

Quoted 10 lines
fs/f2fs/recovery.c +7 -0
+		}
+
+		/*
+		 * it's not needed to clear PG_checked flag in temp page since we
+		 * will truncate all those pages in the end of recovery.
+		 */
+		SetPageChecked(page);
 
 		if (!is_recoverable_dnode(page))
 			break;

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

maintainer
#4 lore raw
Quoted 8 lines · Chao Yu
Quoted 3 lines · Yunlei He

v4 -> v5 return err instead destory inode list for two reasons:
i. avoid duplicated destroy inode list in function recover_fsync_data. ii. report an error for recovery, and set need_fsck flag

fsck can't fix this issue so far, it doesn't work even we set need_fsck flag, would it be better to just drop last dnode with corrupted next_blkaddr and try our best to recover fsynced data?

Yup, agreed to this. There's no way to recover this, if we just return an error.

Quoted 49 lines

Thanks,

Quoted 46 lines

Came across a dead loop in recovery like this:

......

[   24.680480s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597696
[   24.698394s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597697
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724426s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698

......

Mount process will block in dead loop and fsck can do nothing with this error, This patch abandon recovery if node chain is cyclical.

---
 fs/f2fs/recovery.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/recovery.c +11 -0
index d025aa8..a535ec2 100644
@@ -216,6 +216,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 			return 0;
 
 		page = get_tmp_page(sbi, blkaddr);
+		if (PageChecked(page)) {
+			f2fs_msg(sbi->sb, KERN_ERR, "Abandon looped node block list");
+			err = -EINVAL;
+			break;
+		}
+
+		/*
+		 * it's not needed to clear PG_checked flag in temp page since we
+		 * will truncate all those pages in the end of recovery.
+		 */
+		SetPageChecked(page);
 
Quoted 3 lines

fs/f2fs/recovery.c static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) · line 232

Quoted 3 lines
fs/f2fs/recovery.c +0 -0
 		if (!is_recoverable_dnode(page))
 			break;

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

#5 lore raw

Hi, Yunlei,

Could you rework this patch as we discussed?

Thanks,

Quoted 61 lines · Jaegeuk Kim
Quoted 8 lines · Chao Yu
Quoted 3 lines · Yunlei He

v4 -> v5 return err instead destory inode list for two reasons:
i. avoid duplicated destroy inode list in function recover_fsync_data. ii. report an error for recovery, and set need_fsck flag

fsck can't fix this issue so far, it doesn't work even we set need_fsck flag, would it be better to just drop last dnode with corrupted next_blkaddr and try our best to recover fsynced data?

Yup, agreed to this. There's no way to recover this, if we just return an error.

Quoted 49 lines

Thanks,

Quoted 46 lines

Came across a dead loop in recovery like this:

......

[   24.680480s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597696
[   24.698394s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597697
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724334s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724365s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724395s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698
[   24.724426s][pid:320,cpu0,init]find_fsync_dnodes: blkaddr =13597698

......

Mount process will block in dead loop and fsck can do nothing with this error, This patch abandon recovery if node chain is cyclical.

---
 fs/f2fs/recovery.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/recovery.c +11 -0
index d025aa8..a535ec2 100644
@@ -216,6 +216,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
 			return 0;
 
 		page = get_tmp_page(sbi, blkaddr);
+		if (PageChecked(page)) {
+			f2fs_msg(sbi->sb, KERN_ERR, "Abandon looped node block list");
+			err = -EINVAL;
+			break;
+		}
+
+		/*
+		 * it's not needed to clear PG_checked flag in temp page since we
+		 * will truncate all those pages in the end of recovery.
+		 */
+		SetPageChecked(page);
 
Quoted 6 lines
Quoted 3 lines

fs/f2fs/recovery.c static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) · line 232

Quoted 3 lines
fs/f2fs/recovery.c +0 -0
 		if (!is_recoverable_dnode(page))
 			break;

.

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