Re: [PATCH 22/25] fs/buffer: prevent WARN_ON in __alloc_pages_slowpath() when BS > PS

From: Zhang Yi
Date: Sat Oct 25 2025 - 03:02:02 EST


On 10/25/2025 2:32 PM, Baokun Li wrote:
> On 2025-10-25 12:45, Matthew Wilcox wrote:
>> On Sat, Oct 25, 2025 at 11:22:18AM +0800, libaokun@xxxxxxxxxxxxxxx wrote:
>>> + while (1) {
>>> + folio = __filemap_get_folio(mapping, index, fgp_flags,
>>> + gfp & ~__GFP_NOFAIL);
>>> + if (!IS_ERR(folio) || !(gfp & __GFP_NOFAIL))
>>> + return folio;
>>> +
>>> + if (PTR_ERR(folio) != -ENOMEM && PTR_ERR(folio) != -EAGAIN)
>>> + return folio;
>>> +
>>> + memalloc_retry_wait(gfp);
>>> + }
>> No, absolutely not. We're not having open-coded GFP_NOFAIL semantics.
>> The right way forward is for ext4 to use iomap, not for buffer heads
>> to support large block sizes.
>
> ext4 only calls getblk_unmovable or __getblk when reading critical
> metadata. Both of these functions set __GFP_NOFAIL to ensure that
> metadata reads do not fail due to memory pressure.
>
> Both functions eventually call grow_dev_folio(), which is why we
> handle the __GFP_NOFAIL logic there. xfs_buf_alloc_backing_mem()
> has similar logic, but XFS manages its own metadata, allowing it
> to use vmalloc for memory allocation.
>
> ext4 Direct I/O has already switched to iomap, and patches to
> support iomap for Buffered I/O are currently under iteration.
>
> But as far as I know, iomap does not support metadata, and XFS does not
> use iomap to read metadata either.
>
> Am I missing something here?
>

AFAIK, Unless ext4 also manages metadata on its own, like XFS does,
instead of using the bdev buffer head interface. However, this is
currently difficult to achieve.

Best Regards,
Yi.