2024-02-05 03:03:26

by Wu Bo

[permalink] [raw]
Subject: [PATCH] Revert "f2fs: stop allocating pinned sections if EAGAIN happens"

This reverts commit 2e42b7f817acd6e8d78226445eb6fe44fe79c12a.

If the GC victim section has a pinned block when fallocate() trigger
FG_GC, the section is not able to be recycled. And this will return
-EAGAIN cause fallocate() failed, even though there are much spare space
as user see. As the GC policy prone to chose the same victim,
fallocate() may not successed at a long period.

This scenario has been found during Android OTA.

Link: https://lore.kernel.org/linux-f2fs-devel/[email protected]/t/#u

CC: [email protected]
Signed-off-by: Wu Bo <[email protected]>
---
fs/f2fs/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index b58ab1157b7e..19915faccee9 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1725,7 +1725,7 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset,
f2fs_down_write(&sbi->gc_lock);
stat_inc_gc_call_count(sbi, FOREGROUND);
err = f2fs_gc(sbi, &gc_control);
- if (err && err != -ENODATA)
+ if (err && err != -ENODATA && err != -EAGAIN)
goto out_err;
}

--
2.25.1



2024-02-05 03:54:18

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] Revert "f2fs: stop allocating pinned sections if EAGAIN happens"

On 2024/2/5 11:14, Wu Bo wrote:
> This reverts commit 2e42b7f817acd6e8d78226445eb6fe44fe79c12a.
>
> If the GC victim section has a pinned block when fallocate() trigger
> FG_GC, the section is not able to be recycled. And this will return
> -EAGAIN cause fallocate() failed, even though there are much spare space
> as user see. As the GC policy prone to chose the same victim,
> fallocate() may not successed at a long period.
>
> This scenario has been found during Android OTA.
>
> Link: https://lore.kernel.org/linux-f2fs-devel/[email protected]/t/#u
>
> CC: [email protected]
> Signed-off-by: Wu Bo <[email protected]>
> ---
> fs/f2fs/file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index b58ab1157b7e..19915faccee9 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1725,7 +1725,7 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset,
> f2fs_down_write(&sbi->gc_lock);
> stat_inc_gc_call_count(sbi, FOREGROUND);
> err = f2fs_gc(sbi, &gc_control);
> - if (err && err != -ENODATA)
> + if (err && err != -ENODATA && err != -EAGAIN)
> goto out_err;
> }

How about calling f2fs_balance_fs() to double check and make sure there is
enough free space for following allocation.

if (has_not_enough_free_secs(sbi, 0,
GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
f2fs_down_write(&sbi->gc_lock);
stat_inc_gc_call_count(sbi, FOREGROUND);
err = f2fs_gc(sbi, &gc_control);
if (err == -EAGAIN)
f2fs_balance_fs(sbi, true);
if (err && err != -ENODATA)
goto out_err;
}

Thanks,

>

2024-02-08 08:12:18

by Wu Bo

[permalink] [raw]
Subject: Re: [PATCH] Revert "f2fs: stop allocating pinned sections if EAGAIN happens"

On 2024/2/5 11:54, Chao Yu wrote:
> How about calling f2fs_balance_fs() to double check and make sure
> there is
> enough free space for following allocation.
>
>         if (has_not_enough_free_secs(sbi, 0,
>             GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
>             f2fs_down_write(&sbi->gc_lock);
>             stat_inc_gc_call_count(sbi, FOREGROUND);
>             err = f2fs_gc(sbi, &gc_control);
>             if (err == -EAGAIN)
>                 f2fs_balance_fs(sbi, true);
>             if (err && err != -ENODATA)
>                 goto out_err;
>         }
>
> Thanks,

f2fs_balance_fs() here will not change procedure branch and may just
trigger another GC.

I'm afraid this is a bit redundant.

>

2024-02-20 06:51:07

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] Revert "f2fs: stop allocating pinned sections if EAGAIN happens"

On 2024/2/8 16:11, Wu Bo wrote:
> On 2024/2/5 11:54, Chao Yu wrote:
>> How about calling f2fs_balance_fs() to double check and make sure there is
>> enough free space for following allocation.
>>
>>         if (has_not_enough_free_secs(sbi, 0,
>>             GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
>>             f2fs_down_write(&sbi->gc_lock);
>>             stat_inc_gc_call_count(sbi, FOREGROUND);
>>             err = f2fs_gc(sbi, &gc_control);
>>             if (err == -EAGAIN)
>>                 f2fs_balance_fs(sbi, true);
>>             if (err && err != -ENODATA)
>>                 goto out_err;
>>         }
>>
>> Thanks,
>
> f2fs_balance_fs() here will not change procedure branch and may just trigger another GC.
>
> I'm afraid this is a bit redundant.

Okay.

I guess maybe Jaegeuk has concern which is the reason to commit
2e42b7f817ac ("f2fs: stop allocating pinned sections if EAGAIN happens").

Thanks,

>
>>