7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chao Yu [ Upstream commit 894ca8b856668a82426dbd0a0042b61541a1a9ec ] In do_garbage_collect(), we have reserved reference counts on summary cache of all segments, once gc_thread encounter freezing, we need to release all reference counts. Cc: stable@kernel.org Cc: Daeho Jeong Fixes: 02d91398a602 ("f2fs: fix to freeze GC and discard threads quickly") Signed-off-by: Chao Yu Reviewed-by: Daeho Jeong Signed-off-by: Jaegeuk Kim [ sashal: Used folio_put_refs(sum_folio, 2) instead of two f2fs_put_cache() calls. ] Signed-off-by: Sasha Levin --- fs/f2fs/gc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 738a5543f086a..6220d55709e9c 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1857,6 +1857,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, if (block_end_segno > end_segno) block_end_segno = end_segno; + if (unlikely(freezing(current))) + goto next_block; + if (is_cursec(sbi, GET_SEC_FROM_SEG(sbi, segno))) { f2fs_err(sbi, "%s: segment %u is used by log", __func__, segno); @@ -1924,18 +1927,12 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, sbi->next_victim_seg[gc_type] = (cur_segno + 1 < sec_end_segno) ? cur_segno + 1 : NULL_SEGNO; - - if (unlikely(freezing(current))) { - folio_put_refs(sum_folio, 2); - goto stop; - } } next_block: folio_put_refs(sum_folio, 2); segno = block_end_segno; } -stop: if (submitted) f2fs_submit_merged_write(sbi, data_type); -- 2.53.0