]> 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)
commitb234ccb00eec911d658d5e13d16a9e6bb7fc22f0
tree8a5d0b566b4efd1d15900c873ee5b2cf3edae30f
parent391e3cf985d0eb09113493c31ed0f6cf41ee852b
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