Re: [f2fs-dev] [PATCH 03/20] f2fs: extend f2fs_folio_state for subpage blocks

From: Daeho Jeong

Date: Wed Nov 11 2026 - 16:28:00 EST


On Wed, Nov 11, 2026 at 2:40 AM Nanzhe Zhao <nzzhao.sigma@xxxxxxxxx> wrote:
>
> Hi Daeho,
>
> > - Make the uptodate and dirty helpers take block indices. Allocate the
> > state on demand with __GFP_NOFAIL, so callers no longer handle an
> > allocation failure.
>
> I remember you raised this concern when reviewing the large-folio series [1]:
>
> > I understand it is used to avoid failing in-flight I/O or writeback
> > when allocating the subpage state. However, invoking __GFP_NOFAIL in
> > memory reclaim/writeback paths risks OOM livelocks under extreme
> > memory pressure.
> >
> > Ideally, we should ensure ffs is always pre-allocated during
> > write_begin() and page_mkwrite() (where returning -ENOMEM to userspace
> > is safe), so that the writeback path never has to allocate ffs on the
> > fly with __GFP_NOFAIL.
>
> [1] https://lore.kernel.org/linux-f2fs-devel/CACOAw_zD_a32UCJZ+F7zD61o0K8QAh7QKJVuag4fm98qWy7SRQ@xxxxxxxxxxxxxx/
>
> Now this patch uses GFP_NOIO | __GFP_NOFAIL again. May I ask why we changed
> back? Is the livelock concern no longer applicable with the
> subpage-block design?

Hi Nanzhe,

You're right, I changed it and should have explained why.

My earlier concern was about allocating the state in writeback. That is
still avoided: write_begin(), page_mkwrite() and GC attach the state
before a folio is dirtied, so writeback finds it already there. (v1
missed one compressed case. It is fixed in v2.)

The reason for __GFP_NOFAIL is different. With subpage blocks, every
folio with more than one block needs the state, including directory
folios. The helpers that mark blocks dirty or uptodate attach it when it
is missing, and some of their callers cannot return an error, e.g.
f2fs_set_link() and f2fs_delete_entry() are void. So the allocation does
not fail, like ifs_alloc() in iomap.

I will add this to the commit message in v2.

>
> Also, please note the warning reported by the kernel test robot
> (lkp@xxxxxxxxx):
>
> https://lore.kernel.org/linux-f2fs-devel/202611050144.47BOVak5-lkp@xxxxxxxxx/
>
> It reports:
>
> fs/f2fs/data.c:5196:34: warning: variable 'ffs' set but not used

Thanks, I will fix it in v2.

>
> in prepare_large_folio_write_begin(). This appeared after the
> `if (!ffs) return -ENOMEM;` check was removed in this patch. Could you
> please take a look and let me know if you need me to send a fix patch?
>
> Thanks,
> Nanzhe