Skip to contentSkip to conversation

f2fs: fix a infinite loop in gc_node_segment

PATCH In review Yunlei He 2 participants 5 messages Mar 31, 2017 – Apr 6, 2017 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: fix a infinite loop in gc_node_segment

Similar as this problem:
f2fs: relax node version check for victim data in gc

But this patch fix wrong SSA nid.

---
 fs/f2fs/gc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
fs/f2fs/gc.c +19 -0
index c52656c..1d0fd04 100644
@@ -499,6 +499,25 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
 		get_node_info(sbi, nid, &ni);
 		if (ni.blk_addr != start_addr + off) {
 			f2fs_put_page(node_page, 1);
+			node_page = pagecache_get_page(META_MAPPING(sbi), start_addr + off,
+								FGP_LOCK | FGP_CREAT, GFP_NOFS);
+			if (!node_page)
+				continue;
+
+			lock_page(node_page);
+			if (unlikely(node_page->mapping != META_MAPPING(sbi))
+							|| unlikely(!PageUptodate(node_page))) {
+				f2fs_put_page(node_page, 1);
+				continue;
+			}
+
+			get_node_info(sbi, nid_of_node(node_page), &ni);
+			if (ni.blk_addr == start_addr + off) {
+				entry->nid = cpu_to_le32(ni.nid);
+			else
+				f2fs_bug_on(sbi, 1);
+
+			f2fs_put_page(node_page, 1);
 			continue;
 		}
 
Signature · 6 lines
2.10.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 4 lines · Yunlei He

Similar as this problem:
f2fs: relax node version check for victim data in gc

But this patch fix wrong SSA nid.

What was the problem and how does this fix it?

Quoted 11 lines
---
 fs/f2fs/gc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
fs/f2fs/gc.c +0 -0
index c52656c..1d0fd04 100644

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 503

Quoted 5 lines
fs/f2fs/gc.c +2 -0
@@ -499,6 +499,25 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
 		get_node_info(sbi, nid, &ni);
 		if (ni.blk_addr != start_addr + off) {
 			f2fs_put_page(node_page, 1);
+			node_page = pagecache_get_page(META_MAPPING(sbi), start_addr + off,
+								FGP_LOCK | FGP_CREAT, GFP_NOFS);

Why do you think node_page can be cached in meta_inode?

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 507

Quoted 4 lines
fs/f2fs/gc.c +4 -0
+			if (!node_page)
+				continue;
+
+			lock_page(node_page);

Locking the page again? Since FGP_LOCK gave a locked page.

Thanks,

Quoted 27 lines
fs/f2fs/gc.c +13 -0
+			if (unlikely(node_page->mapping != META_MAPPING(sbi))
+							|| unlikely(!PageUptodate(node_page))) {
+				f2fs_put_page(node_page, 1);
+				continue;
+			}
+
+			get_node_info(sbi, nid_of_node(node_page), &ni);
+			if (ni.blk_addr == start_addr + off) {
+				entry->nid = cpu_to_le32(ni.nid);
+			else
+				f2fs_bug_on(sbi, 1);
+
+			f2fs_put_page(node_page, 1);
 			continue;
 		}
 
Signature · 10 lines
2.10.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

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

Hi Jaegeuk,

Quoted 9 lines · Jaegeuk Kim

Hi Yunlei,

Quoted 4 lines · Yunlei He

Similar as this problem:
f2fs: relax node version check for victim data in gc

But this patch fix wrong SSA nid.

What was the problem and how does this fix it?

- has_not_enough_free_secs
- f2fs_gc
- get_victim_by_default
- do_garbage_collect
- gc_node_segment
- ni.blk_addr != start_addr + off
blk_addr = 2668744, node_footer->nid = 10659, sum_entry->nid = 5431
- gc_more select same section

Here, something wrong with sum_entry of this block. Can we fix this error online, or just adding a bug_on here?

Quoted 49 lines
Quoted 12 lines
---
 fs/f2fs/gc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
fs/f2fs/gc.c +0 -0
index c52656c..1d0fd04 100644

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 503

Quoted 5 lines
fs/f2fs/gc.c +2 -0
@@ -499,6 +499,25 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
 		get_node_info(sbi, nid, &ni);
 		if (ni.blk_addr != start_addr + off) {
 			f2fs_put_page(node_page, 1);
+			node_page = pagecache_get_page(META_MAPPING(sbi), start_addr + off,
+								FGP_LOCK | FGP_CREAT, GFP_NOFS);

Why do you think node_page can be cached in meta_inode?

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 507

Quoted 4 lines
fs/f2fs/gc.c +4 -0
+			if (!node_page)
+				continue;
+
+			lock_page(node_page);

Locking the page again? Since FGP_LOCK gave a locked page.

Thanks,

Quoted 20 lines
fs/f2fs/gc.c +13 -1
+			if (unlikely(node_page->mapping != META_MAPPING(sbi))
+							|| unlikely(!PageUptodate(node_page))) {
+				f2fs_put_page(node_page, 1);
+				continue;
+			}
+
+			get_node_info(sbi, nid_of_node(node_page), &ni);
+			if (ni.blk_addr == start_addr + off) {
+				entry->nid = cpu_to_le32(ni.nid);
+			else
+				f2fs_bug_on(sbi, 1);
+
+			f2fs_put_page(node_page, 1);
 			continue;
 		}
 
--

2.10.1

Quoted 10 lines
Quoted 7 lines

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

.

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

maintainer
#3 lore raw
Quoted 13 lines · heyunlei

Hi Jaegeuk,

Quoted 9 lines · Jaegeuk Kim

Hi Yunlei,

Quoted 4 lines · Yunlei He

Similar as this problem:
f2fs: relax node version check for victim data in gc

But this patch fix wrong SSA nid.

What was the problem and how does this fix it?

Quoted 7 lines

- has_not_enough_free_secs
- f2fs_gc
- get_victim_by_default
- do_garbage_collect
- gc_node_segment
- ni.blk_addr != start_addr + off
blk_addr = 2668744, node_footer->nid = 10659, sum_entry->nid = 5431

Can you check the node block written in 2668744?
Does the problem come from wrong sum_entry only?

Thanks,

Quoted 64 lines

- gc_more select same section

Here, something wrong with sum_entry of this block. Can we fix this error online, or just adding a bug_on here?

Quoted 59 lines
Quoted 12 lines
---
 fs/f2fs/gc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
fs/f2fs/gc.c +0 -0
index c52656c..1d0fd04 100644

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 503

Quoted 5 lines
fs/f2fs/gc.c +2 -0
@@ -499,6 +499,25 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
 		get_node_info(sbi, nid, &ni);
 		if (ni.blk_addr != start_addr + off) {
 			f2fs_put_page(node_page, 1);
+			node_page = pagecache_get_page(META_MAPPING(sbi), start_addr + off,
+								FGP_LOCK | FGP_CREAT, GFP_NOFS);

Why do you think node_page can be cached in meta_inode?

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 507

Quoted 4 lines
fs/f2fs/gc.c +4 -0
+			if (!node_page)
+				continue;
+
+			lock_page(node_page);

Locking the page again? Since FGP_LOCK gave a locked page.

Thanks,

Quoted 20 lines
fs/f2fs/gc.c +13 -1
+			if (unlikely(node_page->mapping != META_MAPPING(sbi))
+							|| unlikely(!PageUptodate(node_page))) {
+				f2fs_put_page(node_page, 1);
+				continue;
+			}
+
+			get_node_info(sbi, nid_of_node(node_page), &ni);
+			if (ni.blk_addr == start_addr + off) {
+				entry->nid = cpu_to_le32(ni.nid);
+			else
+				f2fs_bug_on(sbi, 1);
+
+			f2fs_put_page(node_page, 1);
 			continue;
 		}
 
--

2.10.1

Quoted 7 lines

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

.

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

author
#4 lore raw

Hi Jaegeuk,

Quoted 22 lines · Jaegeuk Kim
Quoted 13 lines · heyunlei

Hi Jaegeuk,

Quoted 9 lines · Jaegeuk Kim

Hi Yunlei,

Quoted 4 lines · Yunlei He

Similar as this problem:
f2fs: relax node version check for victim data in gc

But this patch fix wrong SSA nid.

What was the problem and how does this fix it?

Quoted 7 lines

- has_not_enough_free_secs
- f2fs_gc
- get_victim_by_default
- do_garbage_collect
- gc_node_segment
- ni.blk_addr != start_addr + off
blk_addr = 2668744, node_footer->nid = 10659, sum_entry->nid = 5431

Quoted 2 lines

Can you check the node block written in 2668744?
Does the problem come from wrong sum_entry only?

Yeso<
node_footer->nid = 10659, block addr in nat_entry 10659 is 2668744,

fsck just fix the wrong sum_entry nid.

Thanks,

Quoted 68 lines

Thanks,

Quoted 64 lines

- gc_more select same section

Here, something wrong with sum_entry of this block. Can we fix this error online, or just adding a bug_on here?

Quoted 59 lines
Quoted 12 lines
---
 fs/f2fs/gc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
fs/f2fs/gc.c +0 -0
index c52656c..1d0fd04 100644

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 503

Quoted 5 lines
fs/f2fs/gc.c +2 -0
@@ -499,6 +499,25 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
 		get_node_info(sbi, nid, &ni);
 		if (ni.blk_addr != start_addr + off) {
 			f2fs_put_page(node_page, 1);
+			node_page = pagecache_get_page(META_MAPPING(sbi), start_addr + off,
+								FGP_LOCK | FGP_CREAT, GFP_NOFS);

Why do you think node_page can be cached in meta_inode?

fs/f2fs/gc.c static void gc_node_segment(struct f2fs_sb_info *sbi, · line 507

Quoted 4 lines
fs/f2fs/gc.c +4 -0
+			if (!node_page)
+				continue;
+
+			lock_page(node_page);

Locking the page again? Since FGP_LOCK gave a locked page.

Thanks,

Quoted 20 lines
fs/f2fs/gc.c +13 -1
+			if (unlikely(node_page->mapping != META_MAPPING(sbi))
+							|| unlikely(!PageUptodate(node_page))) {
+				f2fs_put_page(node_page, 1);
+				continue;
+			}
+
+			get_node_info(sbi, nid_of_node(node_page), &ni);
+			if (ni.blk_addr == start_addr + off) {
+				entry->nid = cpu_to_le32(ni.nid);
+			else
+				f2fs_bug_on(sbi, 1);
+
+			f2fs_put_page(node_page, 1);
 			continue;
 		}
 
--

2.10.1

Quoted 7 lines

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

.

Quoted 2 lines

.

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