* [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect()
@ 2026-10-16 2:17 Chao Yu
0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2026-10-16 2:17 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, stable, Daeho Jeong
From: Chao Yu <chao@kernel.org>
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 <daehojeong@google.com>
Fixes: 02d91398a602 ("f2fs: fix to freeze GC and discard threads quickly")
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/gc.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 5bb117e5e811..ad6f604cc27f 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1901,6 +1901,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);
@@ -1968,12 +1971,6 @@ 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))) {
- f2fs_put_cache(sum_entry, false);
- f2fs_put_cache(sum_entry, false);
- goto stop;
- }
}
next_block:
f2fs_put_cache(sum_entry, false);
@@ -1981,7 +1978,6 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
segno = block_end_segno;
}
-stop:
if (submitted)
f2fs_submit_merged_write(sbi, data_type);
--
2.49.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-16 2:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 2:17 [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect() Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®