Re: [PATCH v14 101/138] iomap: Convert iomap_page_mkwrite to use a folio

Matthew Wilcox
2021-07-16T03:19:06Z

On Thu, Jul 15, 2021 at 02:41:06PM -0700, Darrick J. Wong wrote:
> > @@ -975,33 +975,33 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
> >
> > vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops)
> > {
> > - struct page *page = vmf->page;
> > + struct folio *folio = page_folio(vmf->page);
>
> If before the page fault the folio was a compound 2M page, will the
> memory manager will have split it into 4k pages before passing it to us?
>
> That's a roundabout way of asking if we should expect folio_mkwrite at
> some point. ;)

Faults are tricky. For ->fault, we need to know the precise page which
the fault occurred on (this detail is handled for you by filemap_fault()).
For mkwrite(), the page will not be split, so it's going to be a matter
of just marking the entire compound page as dirty (in the head page)
and making sure the filesystem is able to write back the entire folio.

Yes, there's going to be some write amplification here. I believe
this will turn out to be a worthwhile tradeoff. If I'm wrong, we can
implement some kind of split-on-fault.