]> git.baikalelectronics.ru Git - kernel.git/commit
f2fs: fix deadloop in foreground GC
authorChao Yu <chao@kernel.org>
Wed, 4 May 2022 06:09:22 +0000 (14:09 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 6 May 2022 17:20:05 +0000 (10:20 -0700)
commitf760c9aca0bd133aba07ef8d67704db6f07631d7
tree8a5d0b566b4efd1d15900c873ee5b2cf3edae30f
parent78465e2287764047a7544f79acedcc84007eea8a
f2fs: fix deadloop in foreground GC

As Yanming reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=215914

The root cause is: in a very small sized image, it's very easy to
exceed threshold of foreground GC, if we calculate free space and
dirty data based on section granularity, in corner case,
has_not_enough_free_secs() will always return true, result in
deadloop in f2fs_gc().

So this patch refactors has_not_enough_free_secs() as below to fix
this issue:
1. calculate needed space based on block granularity, and separate
all blocks to two parts, section part, and block part, comparing
section part to free section, and comparing block part to free space
in openned log.
2. account F2FS_DIRTY_NODES, F2FS_DIRTY_IMETA and F2FS_DIRTY_DENTS
as node block consumer;
3. account F2FS_DIRTY_DENTS as data block consumer;

Cc: stable@vger.kernel.org
Reported-by: Ming Yan <yanming@tju.edu.cn>
Signed-off-by: Chao Yu <chao.yu@oppo.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.h