Skip to content

Commit

Permalink
f2fs: Fix indefinite loop in f2fs_gc()
Browse files Browse the repository at this point in the history
Policy - foreground GC, LFS mode and greedy GC mode.

Under this policy, f2fs_gc() loops forever to GC as it doesn't have
enough free segements to proceed and thus it keeps calling gc_more
for the same victim segment.  This can happen if the selected victim
segment could not be GC'd due to failed blkaddr validity check i.e.
is_alive() returns false for the blocks set in current validity map.

Fix this by not resetting the sbi->cur_victim_sec to NULL_SEGNO, when
the segment selected could not be GC'd. This helps to select another
segment for GC and thus helps to proceed forward with GC.

[Note]
This can happen due to is_alive as well as atomic_file which skipps
GC.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Sahitya Tummala authored and Jaegeuk Kim committed Sep 9, 2019
1 parent cfb9a34 commit 957fa47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/f2fs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
round++;
}

if (gc_type == FG_GC)
if (gc_type == FG_GC && seg_freed)
sbi->cur_victim_sec = NULL_SEGNO;

if (sync)
Expand Down

0 comments on commit 957fa47

Please sign in to comment.