linux-stable/fs/f2fs
Chao Yu 7fc4028010 f2fs: fix deadloop in foreground GC
commit cfd66bb715 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>
2022-06-09 10:23:17 +02:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs: support fault injection for dquot_initialize() 2022-06-09 10:23:13 +02:00
compress.c f2fs: compress: fix to print raw data size in error path of lz4 decompression 2022-04-08 14:23:58 +02:00
data.c f2fs: fix compressed file start atomic write may cause data corruption 2022-04-08 14:23:11 +02:00
debug.c f2fs: use spin_lock to avoid hang 2022-04-08 14:23:58 +02:00
dir.c f2fs: support fault injection for f2fs_kmem_cache_alloc() 2021-08-17 11:59:05 -07:00
extent_cache.c f2fs: support fault injection for f2fs_kmem_cache_alloc() 2021-08-17 11:59:05 -07:00
f2fs.h f2fs: fix to avoid f2fs_bug_on() in dec_valid_node_count() 2022-06-09 10:23:17 +02:00
file.c f2fs: fix to do sanity check on block address in f2fs_do_zero_range() 2022-06-09 10:23:17 +02:00
gc.c f2fs: fix to unlock page correctly in error path of is_alive() 2022-04-08 14:22:52 +02:00
gc.h f2fs: introduce gc_merge mount option 2021-03-30 18:48:56 -07:00
hash.c f2fs: Handle casefolding with Encryption 2020-12-02 22:00:21 -08:00
inline.c f2fs: support fault injection for dquot_initialize() 2022-06-09 10:23:13 +02:00
inode.c f2fs: fix to clear dirty inode in f2fs_evict_inode() 2022-06-09 10:23:17 +02:00
iostat.c f2fs: introduce periodic iostat io latency traces 2021-08-23 10:25:51 -07:00
iostat.h f2fs: introduce periodic iostat io latency traces 2021-08-23 10:25:51 -07:00
Kconfig f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: fix to do sanity check on inline_dots inode 2022-06-09 10:23:13 +02:00
node.c f2fs: fix to avoid potential deadlock 2022-04-08 14:23:11 +02:00
node.h f2fs: swap: support migrating swapfile in aligned write mode 2021-06-23 01:09:35 -07:00
recovery.c f2fs: support fault injection for dquot_initialize() 2022-06-09 10:23:13 +02:00
segment.c f2fs: fix dereference of stale list iterator after loop body 2022-06-09 10:23:13 +02:00
segment.h f2fs: fix deadloop in foreground GC 2022-06-09 10:23:17 +02:00
shrinker.c f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
super.c f2fs: support fault injection for dquot_initialize() 2022-06-09 10:23:13 +02:00
sysfs.c f2fs: fix to enable ATGC correctly via gc_idle sysfs interface 2022-04-08 14:23:10 +02:00
verity.c f2fs: support fault injection for dquot_initialize() 2022-06-09 10:23:13 +02:00
xattr.c f2fs: support fault injection for dquot_initialize() 2022-06-09 10:23:13 +02:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00