Re: [f2fs-dev] [PATCH 13/14] f2fs: allow large folio support to writeable files

From: Daeho Jeong

Date: Wed Sep 09 2026 - 15:32:24 EST


On Sun, Sep 6, 2026 at 11:33 PM Nanzhe Zhao <nzzhao.sigma@xxxxxxxxx> wrote:
>
> On Fri, 28 Aug 2026 10:44:46 -0700, Daeho Jeong wrote:
> > In F2FS, newly created files almost always start with inline_data
> > (`FI_INLINE_DATA`).
> > Because f2fs_has_inline_data() is true during f2fs_new_inode() / f2fs_iget(),
> > mapping_set_large_folios is skipped.
> > When the file later expands and is converted to regular blocks in
> > f2fs_convert_inline_inode(),
> > `f2fs_mapping_set_large_folio()` is NEVER called.
> > As a result, almost NO newly created file will ever use Large Folios
> > during its lifetime.
> > Fix: Call `f2fs_mapping_set_large_folio(inode)` inside
> > `f2fs_convert_inline_inode()` once
> > inline data is converted. Also consider using the standard
> > `mapping_set_large_folios(mapping)`
> > helper instead of `mapping_set_folio_min_order(mapping, 0)`.
>
> I'm concerned that calling mapping_set_large_folios() here would
> violate the specification for enabling large folios on a file, because
> we would be enabling large folios on an active inode. Please take a
> look at the comment of mapping_set_large_folios() in
> include/linux/pagemap.h.

Hi Nanzhe,

Thanks for pointing that out. You are right that calling
mapping_set_large_folios()
on an active inode inside f2fs_convert_inline_inode() violates the pagemap.h
specification due to the non-atomic update on mapping->flags.

However, if you look right above that in include/linux/pagemap.h
(lines 408-414),
it also explicitly states:
"The filesystem should call this funliction in its inode constructor...
Do not tune it based on, eg, i_size."

In F2FS, inline_data is essentially an i_size-based layout optimization (files
<= ~3.4KB), not a persistent file property. Virtually all newly created regular
files start with FI_INLINE_DATA. Tying large folio support to inline_data at
inode creation time violates the rule of not tuning large folio support based on
file size, and permanently prevents almost all newly created files from ever
using large folios even after they grow into large files.

Therefore, we should enable large folios unconditionally for regular files in
the inode constructor (f2fs_new_inode() and f2fs_iget()) by removing the
f2fs_has_inline_data() check from f2fs_mapping_set_large_folio().

Thanks,

>
> Thanks,
> Nanzhe