Skip to contentSkip to conversation

f2fs: fix wrong sum_page pointer in f2fs_gc

PATCH In review Jaegeuk Kim 3 participants 8 messages Oct 12, 2016 – Oct 24, 2016

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix wrong sum_page pointer in f2fs_gc

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +5 -5
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||
+				unlikely(f2fs_cp_error(sbi)))
+			goto next;
+
 		sum = page_address(sum_page);
 		f2fs_bug_on(sbi, type != GET_SUM_TYPE((&sum->footer)));
 
Signature · 1 line
2.8.3
#1 lore raw

Hi Jaegeuk,

Quoted 17 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -2
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 10 lines
fs/f2fs/gc.c +2 -3
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Thanks,

Quoted 7 lines
fs/f2fs/gc.c +3 -0
+				unlikely(f2fs_cp_error(sbi)))
+			goto next;
+
 		sum = page_address(sum_page);
 		f2fs_bug_on(sbi, type != GET_SUM_TYPE((&sum->footer)));
 
author maintainer
#2 lore raw
Quoted 28 lines · Chao Yu

Hi Jaegeuk,

Quoted 25 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -5
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
Quoted 4 lines

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 2 lines
fs/f2fs/gc.c +2 -0
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Well, it looks like no problem to remove this, since it will hit f2fs_cp_error(). I just intended to handle the above f2fs_bug_on here.

I found you added the above bug_on, but it's not a big deal to remain tho. :)

718e53fa: f2fs: enhance foreground GC

Thanks,

Quoted 10 lines

Thanks,

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 869

Quoted 7 lines
fs/f2fs/gc.c +3 -0
+				unlikely(f2fs_cp_error(sbi)))
+			goto next;
+
 		sum = page_address(sum_page);
 		f2fs_bug_on(sbi, type != GET_SUM_TYPE((&sum->footer)));
 

------------------------------------------------------------------------------
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 29 lines · Jaegeuk Kim
Quoted 28 lines · Chao Yu

Hi Jaegeuk,

Quoted 25 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -5
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
Quoted 7 lines
Quoted 4 lines

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 2 lines
fs/f2fs/gc.c +2 -0
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Well, it looks like no problem to remove this, since it will hit f2fs_cp_error(). I just intended to handle the above f2fs_bug_on here.

If summary page becomes non-uptodate, it seems there is a bug in vfs/mm/f2fs, why not keep it there to detect bug?

Thanks,

Quoted 10 lines

I found you added the above bug_on, but it's not a big deal to remain tho. :)

718e53fa: f2fs: enhance foreground GC

Thanks,

Quoted 3 lines

Thanks,

Quoted 16 lines
Quoted 7 lines

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 869

Quoted 7 lines
fs/f2fs/gc.c +3 -0
+				unlikely(f2fs_cp_error(sbi)))
+			goto next;
+
 		sum = page_address(sum_page);
 		f2fs_bug_on(sbi, type != GET_SUM_TYPE((&sum->footer)));
 

------------------------------------------------------------------------------
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 maintainer
#4 lore raw
Quoted 35 lines · Chao Yu
Quoted 34 lines · Jaegeuk Kim
Quoted 32 lines · Chao Yu

Hi Jaegeuk,

Quoted 17 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -2
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 10 lines
fs/f2fs/gc.c +2 -3
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Quoted 5 lines
Quoted 2 lines

Well, it looks like no problem to remove this, since it will hit f2fs_cp_error(). I just intended to handle the above f2fs_bug_on here.

If summary page becomes non-uptodate, it seems there is a bug in vfs/mm/f2fs, why not keep it there to detect bug?

I found that the above get_sum_page() loop can give a page which is not uptodate caused by EIO. Then, we would get the above bug_on, if we move f2fs_cp_error() case like this patch.

Thoughts?

Thanks,

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

maintainer
#5 lore raw
Quoted 39 lines · Jaegeuk Kim
Quoted 38 lines · Chao Yu
Quoted 36 lines · Jaegeuk Kim
Quoted 28 lines · Chao Yu

Hi Jaegeuk,

Quoted 25 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -5
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
Quoted 4 lines

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 2 lines
fs/f2fs/gc.c +2 -0
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Well, it looks like no problem to remove this, since it will hit f2fs_cp_error(). I just intended to handle the above f2fs_bug_on here.

Quoted 8 lines
Quoted 2 lines

If summary page becomes non-uptodate, it seems there is a bug in vfs/mm/f2fs, why not keep it there to detect bug?

I found that the above get_sum_page() loop can give a page which is not uptodate caused by EIO. Then, we would get the above bug_on, if we move f2fs_cp_error() case like this patch.

Thoughts?

Seems this patch has already been merged into linus' tree...

Anyway, I can understand why you remove f2fs_bug_on & add PageUptodate here, but why should we repositon below check?

if (get_valid_blocks(sbi, segno, 1) == 0 ||

		unlikely(f2fs_cp_error(sbi)))

Thanks,

Quoted 3 lines

Thanks,

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

author maintainer
#6 lore raw
Quoted 43 lines · Chao Yu
Quoted 42 lines · Jaegeuk Kim
Quoted 40 lines · Chao Yu
Quoted 29 lines · Jaegeuk Kim
Quoted 28 lines · Chao Yu

Hi Jaegeuk,

Quoted 25 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -5
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
Quoted 7 lines
Quoted 4 lines

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 2 lines
fs/f2fs/gc.c +2 -0
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Well, it looks like no problem to remove this, since it will hit f2fs_cp_error(). I just intended to handle the above f2fs_bug_on here.

If summary page becomes non-uptodate, it seems there is a bug in vfs/mm/f2fs, why not keep it there to detect bug?

Quoted 7 lines
Quoted 5 lines

I found that the above get_sum_page() loop can give a page which is not uptodate caused by EIO. Then, we would get the above bug_on, if we move f2fs_cp_error() case like this patch.

Thoughts?

Seems this patch has already been merged into linus' tree...

Yup.

Quoted 5 lines

Anyway, I can understand why you remove f2fs_bug_on & add PageUptodate here, but why should we repositon below check?

if (get_valid_blocks(sbi, segno, 1) == 0 ||

		unlikely(f2fs_cp_error(sbi)))

Given description, this fixes using wrong sum_page pointer by:

next:

	f2fs_put_page(sum_page, 0);

Thanks,

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

#7 lore raw
Quoted 57 lines · Jaegeuk Kim
Quoted 43 lines · Chao Yu
Quoted 42 lines · Jaegeuk Kim
Quoted 40 lines · Chao Yu
Quoted 29 lines · Jaegeuk Kim
Quoted 28 lines · Chao Yu

Hi Jaegeuk,

Quoted 25 lines · Jaegeuk Kim

This patch fixes using a wrong pointer for sum_page in f2fs_gc.

---
 fs/f2fs/gc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/gc.c +0 -5
index e48142f..9c18917 100644
@@ -854,16 +854,16 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
 	for (segno = start_segno; segno < end_segno; segno++) {
 
-		if (get_valid_blocks(sbi, segno, 1) == 0 ||
-					unlikely(f2fs_cp_error(sbi)))
-			goto next;
-
 		/* find segment summary of victim */
 		sum_page = find_get_page(META_MAPPING(sbi),
 					GET_SUM_BLOCK(sbi, segno));
-		f2fs_bug_on(sbi, !PageUptodate(sum_page));
 		f2fs_put_page(sum_page, 0);
 
Quoted 7 lines
Quoted 4 lines

fs/f2fs/gc.c static int do_garbage_collect(struct f2fs_sb_info *sbi, · line 863

Quoted 2 lines
fs/f2fs/gc.c +2 -0
+		if (get_valid_blocks(sbi, segno, 1) == 0 ||
+				!PageUptodate(sum_page) ||

Why uptodate flag of summary page can be cleared? someone truncates it?

Well, it looks like no problem to remove this, since it will hit f2fs_cp_error(). I just intended to handle the above f2fs_bug_on here.

If summary page becomes non-uptodate, it seems there is a bug in vfs/mm/f2fs, why not keep it there to detect bug?

Quoted 7 lines
Quoted 5 lines

I found that the above get_sum_page() loop can give a page which is not uptodate caused by EIO. Then, we would get the above bug_on, if we move f2fs_cp_error() case like this patch.

Thoughts?

Seems this patch has already been merged into linus' tree...

Yup.

Quoted 3 lines

Anyway, I can understand why you remove f2fs_bug_on & add PageUptodate here, but why should we repositon below check?

Quoted 7 lines
Quoted 2 lines

if (get_valid_blocks(sbi, segno, 1) == 0 ||

		unlikely(f2fs_cp_error(sbi)))

Given description, this fixes using wrong sum_page pointer by:

next:

	f2fs_put_page(sum_page, 0);

That's right, I'm missing this reference. Thanks for the explanation. :)

thanks,

Quoted 12 lines

Thanks,

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