* [f2fs-dev] [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect()
@ 2026-10-16 2:17 Chao Yu via Linux-f2fs-devel
2026-10-16 16:02 ` Daeho Jeong
2026-10-19 15:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
0 siblings, 2 replies; 3+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-10-16 2:17 UTC (permalink / raw)
To: jaegeuk; +Cc: stable, Daeho Jeong, linux-kernel, linux-f2fs-devel
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
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect()
2026-10-16 2:17 [f2fs-dev] [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect() Chao Yu via Linux-f2fs-devel
@ 2026-10-16 16:02 ` Daeho Jeong
2026-10-19 15:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
1 sibling, 0 replies; 3+ messages in thread
From: Daeho Jeong @ 2026-10-16 16:02 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, linux-f2fs-devel, stable, linux-kernel, Daeho Jeong
On Thu, Oct 15, 2026 at 7:22 PM Chao Yu via Linux-f2fs-devel
<linux-f2fs-devel@lists.sourceforge.net> wrote:
>
> 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
>
>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Thanks,
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect()
2026-10-16 2:17 [f2fs-dev] [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect() Chao Yu via Linux-f2fs-devel
2026-10-16 16:02 ` Daeho Jeong
@ 2026-10-19 15:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2026-10-19 15:40 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, linux-f2fs-devel, stable, linux-kernel, daehojeong
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Fri, 16 Oct 2026 10:17:37 +0800 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: fix to avoid potential reference count leak in do_garbage_collect()
https://git.kernel.org/jaegeuk/f2fs/c/894ca8b85666
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-19 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 2:17 [f2fs-dev] [PATCH] f2fs: fix to avoid potential reference count leak in do_garbage_collect() Chao Yu via Linux-f2fs-devel
2026-10-16 16:02 ` Daeho Jeong
2026-10-19 15:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.