Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: Fix indefinite loop in f2fs_gc()

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>

authored by

Sahitya Tummala and committed by
Jaegeuk Kim
957fa478 cfb9a34d

+1 -1
+1 -1
fs/f2fs/gc.c
··· 1326 1326 round++; 1327 1327 } 1328 1328 1329 - if (gc_type == FG_GC) 1329 + if (gc_type == FG_GC && seg_freed) 1330 1330 sbi->cur_victim_sec = NULL_SEGNO; 1331 1331 1332 1332 if (sync)