Skip to contentSkip to conversation

f2fs: continue to do fg_gc even if beyond max_victim_search

PATCH In review Yunlei He 2 participants 3 messages Sep 22, 2016 – Sep 23, 2016 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: continue to do fg_gc even if beyond max_victim_search

For forground gc, if can't find a victim in one max_victim_search, try it again.

---
 fs/f2fs/gc.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
fs/f2fs/gc.c +12 -11
index 24acbbb..19e51a5 100644
@@ -916,24 +916,25 @@ gc_more:
 		goto stop;
 	}
 
-	if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
-		gc_type = FG_GC;
+	if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
 		/*
 		 * If there is no victim and no prefree segment but still not
 		 * enough free sections, we should flush dent/node blocks and do
 		 * garbage collections.
 		 */
-		if (__get_victim(sbi, &segno, gc_type) ||
-						prefree_segments(sbi)) {
-			write_checkpoint(sbi, &cpc);
-			segno = NULL_SEGNO;
-		} else if (has_not_enough_free_secs(sbi, 0, 0)) {
-			write_checkpoint(sbi, &cpc);
-		}
+		gc_type = FG_GC;
+		write_checkpoint(sbi, &cpc);
 	}
 
-	if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))
-		goto stop;
+	if (!__get_victim(sbi, &segno, gc_type)) {
+		if (sync)
+			goto stop;
+		else if (gc_type == FG_GC
+				&& has_not_enough_free_secs(sbi, sec_freed, 0))
+			goto gc_more;
+		else
+			goto stop;
+	}
 	ret = 0;
 
 	if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&
Signature · 4 lines
1.9.1


------------------------------------------------------------------------------
#1 lore raw
Quoted 33 lines · Yunlei He

For forground gc, if can't find a victim in one max_victim_search, try it again.

---
 fs/f2fs/gc.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
fs/f2fs/gc.c +3 -9
index 24acbbb..19e51a5 100644
@@ -916,24 +916,25 @@ gc_more:
 		goto stop;
 	}
 
-	if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
-		gc_type = FG_GC;
+	if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
 		/*
 		 * If there is no victim and no prefree segment but still not
 		 * enough free sections, we should flush dent/node blocks and do
 		 * garbage collections.
 		 */
-		if (__get_victim(sbi, &segno, gc_type) ||
-						prefree_segments(sbi)) {
-			write_checkpoint(sbi, &cpc);
-			segno = NULL_SEGNO;
-		} else if (has_not_enough_free_secs(sbi, 0, 0)) {
-			write_checkpoint(sbi, &cpc);
-		}
+		gc_type = FG_GC;
+		write_checkpoint(sbi, &cpc);

fs/f2fs/gc.c gc_more: · line 934

Quoted 10 lines
fs/f2fs/gc.c +6 -2
 	}
 
-	if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))
-		goto stop;
+	if (!__get_victim(sbi, &segno, gc_type)) {
+		if (sync)
+			goto stop;
+		else if (gc_type == FG_GC
+				&& has_not_enough_free_secs(sbi, sec_freed, 0))
+			goto gc_more;

Will we deadloop here?

Thanks,

fs/f2fs/gc.c gc_more: · line 940

Quoted 7 lines
fs/f2fs/gc.c +3 -0
+		else
+			goto stop;
+	}
 	ret = 0;
 
 	if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&

------------------------------------------------------------------------------

author
#2 lore raw
Quoted 36 lines · Chao Yu
Quoted 35 lines · Yunlei He

For forground gc, if can't find a victim in one max_victim_search, try it again.

---
 fs/f2fs/gc.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
fs/f2fs/gc.c +3 -9
index 24acbbb..19e51a5 100644
@@ -916,24 +916,25 @@ gc_more:
 		goto stop;
 	}
 
-	if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) {
-		gc_type = FG_GC;
+	if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
 		/*
 		 * If there is no victim and no prefree segment but still not
 		 * enough free sections, we should flush dent/node blocks and do
 		 * garbage collections.
 		 */
-		if (__get_victim(sbi, &segno, gc_type) ||
-						prefree_segments(sbi)) {
-			write_checkpoint(sbi, &cpc);
-			segno = NULL_SEGNO;
-		} else if (has_not_enough_free_secs(sbi, 0, 0)) {
-			write_checkpoint(sbi, &cpc);
-		}
+		gc_type = FG_GC;
+		write_checkpoint(sbi, &cpc);
 	}
 
Quoted 11 lines

fs/f2fs/gc.c gc_more: · line 934

Quoted 8 lines
fs/f2fs/gc.c +6 -2
-	if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type))
-		goto stop;
+	if (!__get_victim(sbi, &segno, gc_type)) {
+		if (sync)
+			goto stop;
+		else if (gc_type == FG_GC
+				&& has_not_enough_free_secs(sbi, sec_freed, 0))
+			goto gc_more;

Will we deadloop here?

Does no victim(whole partition) and has_not_enough_free_secs both satisfied at the same time?

If stop FG_GC here, it will come again soon, besides, sec_freed will not change to free segments,

for no checkpoint update.

Thanks,

Quoted 7 lines

Thanks,

Quoted 5 lines
fs/f2fs/gc.c +3 -0
+		else
+			goto stop;
+	}
 	ret = 0;
 
Quoted 6 lines

fs/f2fs/gc.c gc_more: · line 940

Quoted 2 lines
fs/f2fs/gc.c +0 -0
 	if (do_garbage_collect(sbi, segno, &gc_list, gc_type) &&

.

------------------------------------------------------------------------------