]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:25:05 +0000 (09:25 +0200)
commit43dfe21b1c053d7d22e8ea21d2def3b0e4b6310c
treed37339e5e33a73d1441c0778ba5a2211c1ddedde
parent5591bf6883e1cbcad02a54a961cf5f0c72be23d4
f2fs: fix deadloop in foreground GC

BugLink: https://bugs.launchpad.net/bugs/1981864
commit cfd66bb715fd11fde3338d0660cffa1396adc27d upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/f2fs/segment.h