Re: [PATCH v2 6/7] nfs: Optimize direct I/O to use folios for requests

From: Matthew Wilcox

Date: Thu Jun 18 2026 - 14:23:17 EST


On Thu, Jun 18, 2026 at 07:10:45AM -0700, Christoph Hellwig wrote:
> On Tue, Jun 16, 2026 at 05:23:48PM +0000, Pranjal Shrivastava wrote:
> > AFAIU, the MM subsystem explicitly ensures that every valid struct page
> > is part of a folio.
>
> It is definitively not what the vision for the folio is, although if
> I'm not mistaken it actually is still true right now.

It's not true, eg, for slab. While there's still a struct page there
for slab, there's no refcount and flags like PG_locked have different
meanings. You'll get into a lot of trouble trying to treat slabs as
folios (and that will include assertions tripping).

> This whole
> area is a minefield unfortunately, and we also ran into it with
> iov_iter_extract_bvecs and the earlier block code it was extracted
> from. Adding the relevant people and lists, but for now your best
> bet is to stick to what the block code does or even better reuse
> as much as possible of that code.

Yes. Fundamentally, it is no business of the filesystem what the iov_iter
refers to. We can do direct io to slab memory, vmalloc memory, memory
that doesn't have a struct page (eg iomem), or whatever we choose.