On 11/10/25 17:20, Yongpeng Yang wrote:
> On 11/8/25 11:11, Chao Yu via Linux-f2fs-devel wrote:
>> Yunlei,
>>
>> On 2025/11/7 14:29, Yunlei He wrote:
>>> From: Yunlei He <[email protected]>
>>>
>>> GC move fbe data block will add some non uptodate page, we'd
>>> better release it at the end.
>>
>> This is just for saving memory, right?
>>
> 
> Yes, move_data_block() doesn’t read any data to folio, and the GC
> usually selects cold data. Therefore, this folio is typically not
> uptodate, and there’s no need for it to occupy the page cache.
> 
>>>
>>> Signed-off-by: Yunlei He <[email protected]>
>>> Signed-off-by: Yongpeng Yang <[email protected]>
>>> ---
>>>   fs/f2fs/gc.c | 5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
>>> index 8abf521530ff..09b65e6ea853 100644
>>> --- a/fs/f2fs/gc.c
>>> +++ b/fs/f2fs/gc.c
>>> @@ -1315,6 +1315,7 @@ static int move_data_block(struct inode *inode, 
>>> block_t bidx,
>>>       struct node_info ni;
>>>       struct folio *folio, *mfolio;
>>>       block_t newaddr;
>>> +    bool need_invalidate = true;
>>>       int err = 0;
>>>       bool lfs_mode = f2fs_lfs_mode(fio.sbi);
>>>       int type = fio.sbi->am.atgc_enabled && (gc_type == BG_GC) &&
>>> @@ -1450,7 +1451,11 @@ static int move_data_block(struct inode *inode, 
>>> block_t bidx,
>>>   put_out:
>>>       f2fs_put_dnode(&dn);
>>>   out:
>>> +    if (folio_test_uptodate(folio))
>>> +        need_invalidate = false;
>>
>> How about dropping such folio under its lock?
>>
>> if (!folio_test_uptodate())
>>      truncate_inode_partial_folio()
>>
> 
> truncate_inode_partial_folio() is more efficient since it avoids looking
> up the folio again, but it’s declared in mm/internal.h, so it cannot be
> called directly.

Yeah, or generic_error_remove_folio(), not sure.

I just take a look to check whether there is a better alternative scheme.

Thanks,

> 
> Yongpeng,
> 
>>>       f2fs_folio_put(folio, true);
>>> +    if (need_invalidate)
>>> +        invalidate_mapping_pages(mapping, bidx, bidx);
>>>       return err;
>>>   }
>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to