2023-02-16 02:57:55

by Yonggil Song

[permalink] [raw]
Subject: [PATCH v2] f2fs: fix uninitialized skipped_gc_rwsem

When f2fs skipped a gc round during victim migration, there was a bug which
would skip all upcoming gc rounds unconditionally because skipped_gc_rwsem
was not initialized. It fixes the bug by correctly initializing the
skipped_gc_rwsem inside the gc loop.

Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
Signed-off-by: Yonggil Song <[email protected]>

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index b22f49a6f128..81d326abaac1 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1786,8 +1786,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
prefree_segments(sbi));

cpc.reason = __get_cp_reason(sbi);
- sbi->skipped_gc_rwsem = 0;
gc_more:
+ sbi->skipped_gc_rwsem = 0;
if (unlikely(!(sbi->sb->s_flags & SB_ACTIVE))) {
ret = -EINVAL;
goto stop;
--
2.34.1


2023-02-16 07:01:45

by Miko Larsson

[permalink] [raw]
Subject: Re: [PATCH v2] f2fs: fix uninitialized skipped_gc_rwsem

On Thu, 2023-02-16 at 11:57 +0900, Yonggil Song wrote:
> When f2fs skipped a gc round during victim migration, there was a bug
> which
> would skip all upcoming gc rounds unconditionally because
> skipped_gc_rwsem
> was not initialized. It fixes the bug by correctly initializing the
> skipped_gc_rwsem inside the gc loop.
>
> Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
> Signed-off-by: Yonggil Song <[email protected]>
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index b22f49a6f128..81d326abaac1 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -1786,8 +1786,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct
> f2fs_gc_control *gc_control)
>                                 prefree_segments(sbi));
>  
>         cpc.reason = __get_cp_reason(sbi);
> -       sbi->skipped_gc_rwsem = 0;
>  gc_more:
> +       sbi->skipped_gc_rwsem = 0;
>         if (unlikely(!(sbi->sb->s_flags & SB_ACTIVE))) {
>                 ret = -EINVAL;
>                 goto stop;

Might want to Cc the stable mailing list.
--
~miko