OSDN Git Service

f2fs: Fix indefinite loop in f2fs_gc()
authorSahitya Tummala <stummala@codeaurora.org>
Wed, 7 Aug 2019 13:40:32 +0000 (19:10 +0530)
committer0ranko0P <ranko0p@outlook.com>
Tue, 24 Dec 2019 20:42:25 +0000 (04:42 +0800)
commitceb1c35f504a03a76af0213a1c1b583dcb3cb820
tree75e250d9794080526bc1b6053a61c75ab4f0bd9d
parent776a09938867cd8b1e26d58e46a04f9f5b2d87bc
f2fs: Fix indefinite loop in f2fs_gc()

Policy - Foreground GC, LFS 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 keeping track of such invalid segments and skip those
segments for selection in get_victim_by_default() to avoid endless
GC loop under such error scenarios. Currently, add this logic under
CONFIG_F2FS_CHECK_FS to be able to root cause the issue in debug
version.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
[Jaegeuk Kim: fix wrong bitmap size]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/gc.c
fs/f2fs/segment.c
fs/f2fs/segment.h