2022-07-18 03:33:22

by qixiaoyu1

[permalink] [raw]
Subject: [PATCH] f2fs: don't bother wait_ms by foreground gc

f2fs_gc returns -EINVAL via f2fs_balance_fs when there is enough free
secs after write checkpoint, but with gc_merge enabled, it will cause
the sleep time of gc thread to be set to no_gc_sleep_time even if there
are many dirty segments can be selected.

Signed-off-by: qixiaoyu1 <[email protected]>
---
fs/f2fs/gc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index d5fb426e0747..cb8ca992d986 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -150,8 +150,12 @@ static int gc_thread_func(void *data)
gc_control.nr_free_secs = foreground ? 1 : 0;

/* if return value is not zero, no victim was selected */
- if (f2fs_gc(sbi, &gc_control))
- wait_ms = gc_th->no_gc_sleep_time;
+ if (f2fs_gc(sbi, &gc_control)) {
+ /* don't bother wait_ms by foreground gc */
+ if (!foreground) {
+ wait_ms = gc_th->no_gc_sleep_time;
+ }
+ }

if (foreground)
wake_up_all(&gc_th->fggc_wq);
--
2.36.1


2022-07-22 02:53:57

by Jaegeuk Kim

[permalink] [raw]
Subject: Re: [PATCH] f2fs: don't bother wait_ms by foreground gc

On 07/18, qixiaoyu1 wrote:
> f2fs_gc returns -EINVAL via f2fs_balance_fs when there is enough free
> secs after write checkpoint, but with gc_merge enabled, it will cause
> the sleep time of gc thread to be set to no_gc_sleep_time even if there
> are many dirty segments can be selected.
>
> Signed-off-by: qixiaoyu1 <[email protected]>
> ---
> fs/f2fs/gc.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index d5fb426e0747..cb8ca992d986 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -150,8 +150,12 @@ static int gc_thread_func(void *data)
> gc_control.nr_free_secs = foreground ? 1 : 0;
>
> /* if return value is not zero, no victim was selected */
> - if (f2fs_gc(sbi, &gc_control))
> - wait_ms = gc_th->no_gc_sleep_time;
> + if (f2fs_gc(sbi, &gc_control)) {
> + /* don't bother wait_ms by foreground gc */
> + if (!foreground) {
> + wait_ms = gc_th->no_gc_sleep_time;
> + }

I applied without {} to match the coding style.

Thanks,

> + }
>
> if (foreground)
> wake_up_all(&gc_th->fggc_wq);
> --
> 2.36.1

2022-07-22 03:59:34

by qixiaoyu1

[permalink] [raw]
Subject: [PATCH v2] f2fs: don't bother wait_ms by foreground gc

f2fs_gc returns -EINVAL via f2fs_balance_fs when there is enough free
secs after write checkpoint, but with gc_merge enabled, it will cause
the sleep time of gc thread to be set to no_gc_sleep_time even if there
are many dirty segments can be selected.

Signed-off-by: qixiaoyu1 <[email protected]>
---
fs/f2fs/gc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index d5fb426e0747..e2f8a2dae908 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -150,8 +150,11 @@ static int gc_thread_func(void *data)
gc_control.nr_free_secs = foreground ? 1 : 0;

/* if return value is not zero, no victim was selected */
- if (f2fs_gc(sbi, &gc_control))
- wait_ms = gc_th->no_gc_sleep_time;
+ if (f2fs_gc(sbi, &gc_control)) {
+ /* don't bother wait_ms by foreground gc */
+ if (!foreground)
+ wait_ms = gc_th->no_gc_sleep_time;
+ }

if (foreground)
wake_up_all(&gc_th->fggc_wq);
--
2.36.1

2022-07-24 10:07:48

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] f2fs: don't bother wait_ms by foreground gc

On 2022/7/22 10:40, Jaegeuk Kim wrote:
> On 07/18, qixiaoyu1 wrote:
>> f2fs_gc returns -EINVAL via f2fs_balance_fs when there is enough free
>> secs after write checkpoint, but with gc_merge enabled, it will cause
>> the sleep time of gc thread to be set to no_gc_sleep_time even if there
>> are many dirty segments can be selected.
>>
>> Signed-off-by: qixiaoyu1 <[email protected]>

>
> I applied without {} to match the coding style.

Reviewed-by: Chao Yu <[email protected]>

Thanks,